My iPhone application is displaying some odd behavior when run on the iPad with respect to supporting orientation changes.
The app starts up with a view controller (
Apple states:
Case: All child view controllers in your UITabBarController or UINavigationController do not agree on a common orientation set.
Response: To make sure that all your child view controllers rotate correctly, you must implement shouldAutorotateToInterfaceOrientation for each view controller representing each tab or navigation level. Each must agree on the same orientation for that rotate to occur. That is, they all should return YES for the same orientation positions.
http://developer.apple.com/iphone/library/qa/qa2010/qa1688.html
You may be able to set device orientation within the navigation controller instead of within individual views. Then you could check which view is on the stack and rotate based on the result. In this way, the navigation controller handles all orientation as well.
Here is some code i'm using to prevent that error:
- (void)viewDidLoad {
if (self.interfaceOrientation == UIInterfaceOrientationPortrait) {
self.view.transform = CGAffineTransformIdentity;
self.view.transform = CGAffineTransformMakeRotation(M_PI/2);
self.view.bounds = CGRectMake(0.0, 0.0, 480, 320);
}
[UIView commitAnimations];
}
and
- (void)viewDidLoad {
if (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
self.view.transform = CGAffineTransformIdentity;
self.view.transform = CGAffineTransformMakeRotation(-(M_PI / 2));
self.view.bounds = CGRectMake(0, 0, 320, 480);;
}
[UIView commitAnimations];
}
Based on what orientation the device is in, you will need to modify some of the code.