iOS9竖屏处理方法

Xcode升级到7.0,iOS升级到9.0后,发现原来设置不旋转的方法失效了。在网上发现需要如下设置:

1. 在ViewController里面设置

/* iOS6后被废弃了,使用接下来的两个方法,并且要在Deloyment info勾上requires full screen */
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

/* 是否支持旋转 */
- (BOOL)shouldAutorotate {
    return NO;
}

/* 支持的方向 */
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationPortrait;
}

2. 在AppDelegate插入

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    return UIInterfaceOrientationMaskPortrait;
}

3. 在General里面勾上Requires full screen

iOS9竖屏处理方法_第1张图片

 

你可能感兴趣的:(iOS9竖屏处理方法)