For the more curious: overriding autorotation


At the very end of chapter 8 (in the “fore the more curious” paragraph) the last sentence says: “Make sure, however, that you do not replace the view of the view controller in this method. If yo wish to swap in another view, you must swap a subview of the view controller’s view”.
I’d be curious to understand why is that…


A view controller manages its own view and the lifecycle of that view (you’ll see the details of this in the next chapter). You should never send setView: to a view controller outside of its loadView method.

One reason, particularly for this case: when a view controller is set as the root view controller of the window, its view is added as a subview of that window. If you were to create a new view and set it as the view of the view controller, it is not going to insert it as a subview of the window, thus it won’t appear on the screen. Not only that, the view that is on the screen is now “disconnected” from the view controller.


Thanks Joe for you reply, that makes sense now, particularly considering your example of what would happen with a window’s root VC.