【发布时间】:2016-04-11 20:30:32
【问题描述】:
我有一个锁定为纵向的视图控制器(带有子视图控制器),使用以下代码来完成此操作:
- (UIInterfaceOrientationMask) supportedInterfaceOrientations {
if ([self.centerViewController respondsToSelector:@selector(supportedInterfaceOrientations)]) {
return [self.centerViewController supportedInterfaceOrientations];
}
return UIInterfaceOrientationMaskAll;
}
这非常有效,如果我需要锁定该视图,我可以“覆盖”当前 centerViewController 中的 supportedInterfaceOrientations,如果我希望该视图支持所有内容,则可以将其排除在外。
问题是锁定的视图在导航时不会旋转到其支持的方向。一个视图被锁定为纵向,但是当以横向显示另一个视图并导航到该视图时,它以横向显示,即使此视图不支持横向。
如何确保在导航时将视图旋转到允许的方向?
【问题讨论】:
标签: ios cocoa-touch ios8 ios9