UIViewController and UITabBarController app - viewDidLoad called only once

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.



viewDidLoad will be called only once for each time when the view has been inited. 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.

Maybe try using -(void)viewWillAppear:(BOOL)animated {...} instead of viewDidLoad?

Need Your Help

Create QR Barcodes on Mac

objective-c osx cocoa qr-code

I'm creating an app for mac which needs to create QR barcodes as a part of the application.

Error deserializing JSON that's been converted from XML first

.net xml json serialization json.net

I'm creating a .net app that manages some feeds from various web services. I've just started using JSON.NET and I'm looking to do all my conversion to my .net objects from JSON.