I’m making an application for the iPad.
I have a view controll that has to stay in landscape, this works just fine.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}
From this view i push towards an other view, this child view should rotate to the appropriate rotation (landscape or portrait) whenever the user tilts his ipad.
in this child view i use this code to make this happen, but it doesn’t work. It sticks to the landscape.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
In order for a view controller to support rotation, all view controllers in its hierarchy must support rotation.
From the Responding to Orientation Changes documentation:
Further, you should not be using multiple view controllers to manage a single screen.
From the View Controller Programming Guide documentation (emphasis mine):
In this case, I’d suggest disabling rotation handling in your parent view controller, changing the child view controller to be simply a view (to meet the above criteria), and manually monitoring orientation changes to update your child view’s layout.
You can monitor for orientation changes by listening for the
UIDeviceOrientationDidChangeNotificationnotification. Example code:Update
If by “push” you mean push a view controller onto a navigation view controller then please disregard the second part of my response.
If this is the case, you must ensure that you have overridden the
shouldAutorotateToInterfaceOrientation:method of your navigation controller to returnYESas well as your view controller in order to support rotation handling.