Reputation: 1323
No matter which way i turn the iPad, the viewcontroller.interfaceOrientation always returns 1. Anyone know why this is?
Upvotes: 3
Views: 1491
Reputation: 6721
This problem seems to disappear in iOS 6.0.
A workaround could look like this:
- (UIInterfaceOrientation)interfaceOrientation;
{
UIViewController *rootViewController = self.view.window.rootViewController;
if (rootViewController) {
return rootViewController.interfaceOrientation;
}
return [super interfaceOrientation];
}
Upvotes: 0
Reputation: 3026
It completely depends where your viewcontroller sits in the view heirarchy.
UIWindow should only have a single viewcontroller linked to it (usually a rootViewController) and this is the viewcontroller that responds to the rotation. If the rootViewController has multiple children viewcontrollers, you'll need to detect the rotation in the rootViewController and pass it on to the relevant viewcontroller
There's a very good programming guide in the online docs about it. If I find the link I'll post it. Search my previous posts where I was pointed in the same direction.
Upvotes: 1