I've noticed a lot of examples for iPhone apps in the Application Delegate
- (void)applicationDidFinishLaunching:(UIApplication *)application
have
[window addSubview: someController.view];
(1)
as opposed to
self.window.rootViewController = self.someController;
(2)
Is there any practical reason to use one over the other? Is one technically correct? Do controller's have an equivalent command to number (2) like
self.someController.rootController = self.someOtherController; // pseudocode
The UIWindow
rootViewController
property is new with iOS4.
The older technique was to use addSubview
.
The new, recommended technique is to set rootViewController
.
Just an update on this with the release of ios 6.
If still using the -[UIWindow addsubview:] boilerplate, you will probably get the message "Application windows are expected to have a root view controller at the end of application launch" in your console as well now. Along with potential rotation issues and layout issues in your app.
Setting the window's rootViewController as above will fix this too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With