简体   繁体   中英

iOS 6 landscape orientation problems

In iOS, after dismissing a modal view controller (which is being forced to only show in portrait orientation), if the device is being held in landscape mode, the view controller which presented the modal view controller doesn't rotate back to landscape correctly.

The 'willAnimateRotationToInterfaceOrientation' method gets called so I can manage rotation of my subviews etc. but then the actual view controller doesn't rotate to landscape. So my subviews look like they should in landscape, but the interface is in portrait mode.

The annoying thing is that it works fine in the iOS 5 simulator. Ie. After dismissing the modal view controller, the presenting view controller rotates back to landscape orientation.

Has anyone experienced something similar, or have any idea how to approach this?

For IOS 6 u need to handle the orientation with this methods.

- (BOOL)shouldAutorotate; {
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations; {
    if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
        return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
    }
    else{
        return UIInterfaceOrientationMaskLandscape;
    }
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation; {
    if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
        return UIInterfaceOrientationPortrait;
    }
    else{
        return UIInterfaceOrientationLandscapeLeft;
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM