shouldAutorotateToInterfaceOrientation doesn’t work

Make sure all of your parent views have autoresizesSubviews = YES. You may need to do this in code if you haven’t set springs and struts in IB for all of your views.

Quoting the Interface Builder User’s Guide:

Important: In a Cocoa nib file, if you
do not set any springs or struts for
your view in Interface Builder but
then do use the setAutoresizingMask:
method to add autosizing behavior at
runtime, your view may still not
exhibit the correct autoresizing
behavior. The reason is that Interface
Builder disables autosizing of a
parent view’s children altogether if
those children have no springs and
struts set. To enable the autosizing
behavior again, you must pass YES to
the setAutoresizesSubviews: method of
the parent view. Upon doing that, the
child views should autosize correctly.

A couple other things to be aware of:

  1. A UINavigationController will only autorotate if its root view controller is also set to autorotate.

  2. A UITabBarController will only autorotate if all of its view controllers are set to autorotate.

Leave a Comment