2

Since iOS6, I realize that the shouldAutorotateToInterfaceOrientation: method has been deprecated. Most of my app I would like the user to be able to rotate, which does work in iOS6 and 5 currently. But, I have a modal view that I ONLY want to be portrait, so I have added the following without it actually working (tested in simulator and device):

// Tell the system what we support
- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationPortrait;
}

// Tell the system It should autorotate
- (BOOL) shouldAutorotate {
    return NO;
}

// Tell the system which initial orientation we want to have
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationPortrait;
}

Why isn't this code preventing my modal from rotating? How can I still support the iOS5 method as well as the iOS6 methods without crashing for users on iOS5?

4

2 に答える 2

3

You have to embed the presented vc in a navigation controller where you can set the preferred orientation.

https://stackoverflow.com/a/12522119

于 2012-11-14T17:46:33.570 に答える
0

You missed to but this line inside your -(void)viewDidLoad method

[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"UIApplicationSupportedInterfaceOrientationsIsEnabled"];

I hope this can help you

于 2012-11-15T13:43:28.823 に答える