【发布时间】:2016-02-21 08:58:27
【问题描述】:
我有一个应用支持纵向和横向。但在视图控制器中,我只希望它以横向模式呈现。我尝试覆盖一些改变方向的方法,例如
- (BOOL)shouldAutorotate {
return NO;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return (UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight);
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
return YES;
}
return NO;
}
但是在 iOS 9 中它们都没有被调用。因此,这个视图控制器同时呈现纵向和横向。相反,它在 iOS 8 中完美运行。
太烦人了,有没有办法强制在 iOS 9 中以横向模式显示视图控制器
更新: 正如 Ronak Chaniyara 的回答,我解决了我的问题,只有一个控制器处于横向模式。 现在我面临另一个问题。如果我想强制一个控制器处于纵向模式,我会在控制器中实现这些方法,但如果我旋转屏幕,它仍然会旋转。
解决方案是否仍然适用于纵向模式,或者我必须找到另一种方法来强制控制器处于纵向模式
【问题讨论】:
标签: ios uiviewcontroller orientation landscape-portrait