shouldAutorotateToInterfaceOrientation with iPad and iPhone differences
I have an iPhone app which I have created as a universal iPad/iPhone app. I've implemented a splitviewcontroller for the iPad version... all fine.
In my iPhone app, everything is in Portrait, except for a 2nd level view controller (a web view), which I override shouldAutorotateToInterfaceOrientation to allow landscape. On returning up the view chain I go back to portrait.. Excellent!
However, Now my iPad split view app is forced to stay in portrait. If I override shouldAutorotateToInterfaceOrientation in any of my views like rootviewcontroller or others it effectively allows landscape mode in my iPhone app which I canno开发者_运维百科t do. However it does fix my landscape problem in the iPad.
Is there a way round this? I effectively want to say YES to shouldAutorotateToInterfaceOrientation for iPad, but no for iPhone. I tried this, but it doesnt work, it allows landscape on both devices:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
BOOL rotate = NO;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
rotate = YES;
}
return rotate;
}
Any advice?
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
return YES;
} else {
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
精彩评论