My current application consists of a UITabBarController with 4 different tabs and a UIViewController. My tabBarController is the rootController and the UIViewController is primarily being used for my user login view. When the application loads both views are loaded with the login view covering the tabBar.
I have added some logging to my viewDidLoad method for the loginViewController. I see this method being called on initial launch. Once the user successfully logs in, the tabBarController view is now viewable. I setup an action to logout from the tabBarController. This method sets user/pass to nil and calling a delegate method to load my loginView again.
-(void)setLoginView { [window addSubview:loginController.view];
} 开发者_如何学运维I'm adding some checks but nothing is firing because viewDidLoad (in loginViewController.m)never gets called again. When logging out my text fields still have the user/pass that was entered when I first logged in. So one of my checks is to reset the text fields to nil etc..
I may be using the wrong terminology here but is there anyway to "refresh" this loginController where the viewDidLoad method is called every time the user will log out?
Also for the record. I can't thank everyone enough that has helped answer my previous questions. It has really helped and I appreciate it.
Thanks
Maybe try using -(void)viewWillAppear:(BOOL)animated {...}
instead of viewDidLoad?
viewDidLoad
will be called only once for each time when the view has been init
ed. I'm not sure if doing loginController.view = nil
will cause view to unloaded or not, but I think it should work so next time you access view
property the view will be loaded again.
精彩评论