I had a similar problem when it was caused when I added a view controller that I wanted to add to the window using the MainWindow.xib file.
To get around this, I assigned the rootViewController window (you can also call addSubView, but it's better to assign rootViewController) in the didFinishLaunchingWithOptions: method of the application delegate. Once you do this, you can easily put any logic that you need, in front or behind where this happens. It allows you full control when your controller boots up. On the contrary, when the view controller is loaded through the tip, it is difficult for him to execute the code in front of him (if at all possible). I know that you specify the main xib in the application, but I do not know if there is a way to run the code before nib loads.
In general, I avoid adding a view controller to xib for this reason.
My code is more like:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // special pre load logic here... UIViewController *myVC = [[MyAwesomeViewController alloc] init]; self.window.rootViewController = myVC; [myVC release]; // special post load logic here... [self.window makeKeyAndVisible]; return YES; }
source share