UIViewController Looks Out for Itself, Not Its Ownon 23 March 2011

A difference exists in iOS between a UIViewController and a navigation controller (UINavigationController + UITabBarController). One is being used to control views, the latter is used to control collections of view controllers. This fundamental difference creates a rift for the purposes of a recent iPad project.

The main problem is that Apple and Xcode do not recommend that a UINavigationController be used as the main iPad app view controller. It strikes me as strange, though the main reason I could find from the HIG is that an iPad app should do everything it can to not change fullscreen views, or more succinctly from the Apple Human Interface Guidelines:

When you perform fewer full-screen transitions, your iPad app has greater visual stability, which helps people keep track of where they are in their task. You can use UI elements such as split view and popover to lessen the need for full-screen transitions.

The HIG has guidelines, not hard and fast rules. Apple’s app “Remote” does not follow this convention (an example that scrapes the bottom of the barrel). However Apple does consider this to be an “OK!” practice when used with a UITabBarController because the buttons at the bottom illicit an expected behavior that the whole screen will change.

The code in problem–causing question is being written to be reused in a various number of situations. The issue is UIViewControllers do not pass on rotation information to their children. Other developers may not know this fact when using the code and will try to figure out why their view controllers are not responding to rotation orientations. UINavigationControllers, conversely, do pass on orientation changes. UINavigationControllers also—through Apple code magic—set the read only variable parentViewController on the rootViewController that is used.

So to prevent the following code from being written each time for other developers to fix the UIViewController in a UIViewController issue.

Sounds like a blast, especially if any of those methods requires case–coding.

Interface orientation changes may not be the only events that are not passed on to children view controllers, however it is one of the features of a UIViewController that is sorely missed when contained inside of another view controller.