扫码关注官方订阅号
App中其它界面都是竖屏, 只有一个界面是需要横屏的, 怎样使这个界面强制横屏布局?
光阴似箭催人老,日月如移越少年。
如果需要特定ViewController旋转, 可以为UINavigationController添加Category(类目)UINavigationController+InterfaceOrientation, 然后在指定的ViewController中调用即可.
@implementation UINavigationController (InterfaceOrientation) - (BOOL)shouldAutorotate { if ([self.topViewController respondsToSelector:@selector(shouldAutorotate)]) { return [self.topViewController shouldAutorotate]; } return NO; } - (UIInterfaceOrientationMask)supportedInterfaceOrientations { if ([self.topViewController respondsToSelector:@selector(supportedInterfaceOrientations)]) { return [self.topViewController supportedInterfaceOrientations]; } return [super supportedInterfaceOrientations]; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { if ([self.topViewController respondsToSelector:@selector(preferredInterfaceOrientationForPresentation)]) { return [self.topViewController preferredInterfaceOrientationForPresentation]; } return [super preferredInterfaceOrientationForPresentation]; } @end
另外, 推荐一篇博文: http://www.molotang.com/articles/1530.html. 对于不同级别的屏幕旋转梳理的较为清晰.
使用如下这种方式,在需要横屏的页面添加。
- (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { return UIInterfaceOrientationIsLandscape(toInterfaceOrientation); }
那怎么保证其它界面始终是竖屏呢
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
如果需要特定ViewController旋转, 可以为UINavigationController添加Category(类目)UINavigationController+InterfaceOrientation, 然后在指定的ViewController中调用即可.
另外, 推荐一篇博文: http://www.molotang.com/articles/1530.html. 对于不同级别的屏幕旋转梳理的较为清晰.
使用如下这种方式,在需要横屏的页面添加。
那怎么保证其它界面始终是竖屏呢