iOS技术交流iOS点点滴滴iOS

IOS在指定的控制器支持屏幕旋转

2016-11-23  本文已影响493人  NSLogGPX
- (BOOL)shouldAutorotate;
- (UIInterfaceOrientationMask)supportedInterfaceOrientations;
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation;
 - (BOOL)shouldAutorotate{
 // 返回当前显示的viewController是否支持旋转
    return [self.visibleViewController shouldAutorotate];
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
// 返回当前显示的viewController支持旋转的方向
    return [self.visibleViewController preferredInterfaceOrientationForPresentation];
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
// 返回当前显示的viewController是优先旋转的方向
    if (![self.visibleViewController isKindOfClass:[UIAlertController class]]) {//iOS9 UIWebRotatingAlertController
        return [self.visibleViewController supportedInterfaceOrientations];
    }else{
        return UIInterfaceOrientationMaskPortrait;
    }
}
- (BOOL)shouldAutorotate {
   return YES;
}

// 这里返回需要支持旋转的方向
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
    return UIInterfaceOrientationLandscapeLeft;
}
// 优先显示的方向
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}

上一篇 下一篇

猜你喜欢

热点阅读