iOS 9 supportedInterfaceOrientations不工作 [英] iOS 9 supportedInterfaceOrientations not working

查看:327
本文介绍了iOS 9 supportedInterfaceOrientations不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UIViewController 与以下代码:

- (BOOL) shouldAutorotate {
     return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationPortrait;
}

我没有使用 UINavigationController 。当显示此 UIViewController 时,设备仍将旋转到横向。我的目标是iOS 9,这里有什么问题?

I am not using a UINavigationController. When this UIViewController is being displayed, the device will still rotate to landscape. I am targeting iOS 9, what's the issue here?

推荐答案

所以问题是我已经定义了允许的方向<

So the issue was that I had defined the allowed orientations in info.plist which apparently overrides anything you do anywhere else throughout the project.

为了纠正这个问题,我删除了项目 info.plist 并在项目设置中定义它们。现在一切正常。

To correct the issue I removed the entries from info.plist and defined them in the project settings. Now everything works as expected.

这篇关于iOS 9 supportedInterfaceOrientations不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆