模态UIViewController
的父级自动旋转,但是当模态 VC 启动时,我只希望它以纵向显示而不是可旋转。我试过简单地返回 NOshouldAutorotate
...在模态VC中,但没有欢乐。支持 iOS 5+。
非常感谢任何帮助。
基本上,如果您在任何容器控制器(即 UINavigationController)它有自动旋转方法返回YES默认情况下。因此,您必须为导航控制器创建子类并在那里弃用自动旋转。
对于iOS 5使用方法:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return (toInterfaceOrientation == UIInterfaceOrientationPortrait) : self.enableRotations;
}
对于 iOS 6:
- (NSUInteger)supportedInterfaceOrientations {
switch ([UIDevice currentDevice].userInterfaceIdiom) {
case UIUserInterfaceIdiomPad: return UIInterfaceOrientationMaskAll;
case UIUserInterfaceIdiomPhone: return UIInterfaceOrientationMaskPortrait;
}
}
- (BOOL)shouldAutorotate {
return NO;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)