环境:IOS7,iPhone5。大家都知道写法:
// 是否支持屏幕旋转
- (BOOL)shouldAutorotate {
return YES;
}
// 支持的旋转方向
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAllButUpsideDown;//UIInterfaceOrientationMaskAllButUpsideDown;
}
// 一开始的屏幕旋转方向
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;
}
如果我的原VC是横屏,但是弹出来一个要竖屏的怎么办?看代码:
方法如下:
// 是否支持屏幕旋转
- (BOOL)shouldAutorotate {
return NO;
}
/* // 支持的旋转方向 不能重写这个函数,否则崩溃
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAllButUpsideDown;//UIInterfaceOrientationMaskAllButUpsideDown;
}*/
// 一开始的屏幕旋转方向
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;
}
本文详细介绍了在iOS7环境下,针对iPhone5设备,如何通过修改代码实现从横屏状态转换为竖屏状态。包括了是否支持屏幕旋转、支持的旋转方向以及初始屏幕旋转方向的设置。
893

被折叠的 条评论
为什么被折叠?



