[ self presentModalViewController: controller animated: YES ]; Behaves strangely
I have an Universal App that supports all orientations in iPad and only potrait in iPhone / iPod. My code looks somewhat like this:
@implementation UIViewController ( interfaceOrientationHack )
- (void) shouldAutorota开发者_运维百科teToInterfaceOrientation: ( UIInterfaceOrientation ) toInterfaceOrientation {
if( iPad ) {
return YES;
} else if( toInterfaceOrientation == UIInterfaceOrientationPotrait ) {
return YES;
} else return NO;
}
@end
From one of my controllers, i launch a navigation controller as modal view controller
[ self presentModalViewController: c animated: YES ];
The issue currently is, the modal controller launches correctly in orientation, But when i change my orientation the the modal controller doesn't change its orientation, all the rest of the controllers behave correctly.
Any help will be hugely appreciated. Thanks in advance.
From UIViewcontroller class reference:"By default, the UIViewController class displays views in portrait mode only. To support additional orientations, you must override the shouldAutorotateToInterfaceOrientation: method and return YES for any orientations your subclass supports. If the autoresizing properties of your views are configured correctly, that may be all you have to do."
Since your modal view inherits from UIViewcontroller, you have to override shouldAutorotateToInterfaceOrientation:in your modal view.
精彩评论