当呈现UIModalPresentationCustom
的模式时,它将忽略方向方法,并显示/旋转到呈现VC配置的任何位置。UIModalPresentationCustom调整方向设置
例:
- 呈现VC支持横向和纵向。
- 主办VC支持肖像仅(通过
preferredInterfaceOrientationForPresentation
和supportedInterfaceOrientations
。
当在景观呈现它没有UIModalPresentationCustom
,它旋转视图回纵向,则呈现出VC相应。不幸的是,因为我需要的提出VC保持在下面可见,我不得不使用UIModalPresentationCustom
当发生这种情况时,呈现的VC被强制进入横向模式,创建了一个混乱的用户界面并产生约束问题,即使以纵向呈现,它也可以旋转成景观,忽略shouldAutorotate
返回编号
PS:我发现在iOS 7的解决方法,加入这个方法我的应用程序代理,但它不解决它在iOS 8
@implementation UIViewController (customModalFix)
- (BOOL)shouldAutorotate
{
if ([self.presentedViewController isKindOfClass:[IntroViewController class]]) {
return [self.presentedViewController shouldAutorotate];
}
return YES;
}
@end
编辑:上呈现VC实现supportedInterfaceOrientations
没有按根本没有帮助,因为只有当视图被加载时才会调用它,而不是当VC将要被呈现时才被调用。仍然没有找到解决这个问题的办法。
我今天碰上了同样的问题,这里是解决方案: http://stackoverflow.com/a/29560217/1658831 – Pauls 2015-04-10 11:26:51