Free the view / previous view controller
My app has a login page and then a home page. I want to free up the login page when the user logs in, and since the main page is heavy, I obviously want it to be released when I log out and go back to the login page. How do you achieve this? I use presentModalViewController
, but I believe that memory consumption does not decrease when logging out with this method. Will there be a navigation controller (with a method pushViewController
)? How to dismiss / free / ignore / previous view controller?
source to share
Try using a tab bar controller with a hidden tab. Just make one tab is the login screen, the other is the main screen of the application. When the user is logged in, just show the app screen and then set the view controllers of the initial tab bar controller to only one vc - the main vc app. And make sure you set all applicable properties to nil so that ARC does the job and free up the login screen.
source to share
You can achieve with this code:
MainViewController *mainController = [MainViewController new];
UIWindow *mainWindow = [[[UIApplication sharedApplication] windows] firstObject];
[mainWindow.rootViewController removeFromParentViewController];
[mainWindow setRootViewController:mainController];
source to share