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?

+3


source to share


3 answers


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.



+2


source


The view controller uses the concept of a stack, so there must be a root view controller to control the switch. You have one main view controller, which is mostly empty, and add two other controllers to it as needed.



0


source


You can achieve with this code:

MainViewController *mainController = [MainViewController new];
UIWindow *mainWindow = [[[UIApplication sharedApplication] windows] firstObject];
[mainWindow.rootViewController removeFromParentViewController];
[mainWindow setRootViewController:mainController];

      

0


source







All Articles