如何在iPad应用程序上禁用横向取向? [英] How do I disable landscape-orientation on an iPad app?

查看:87
本文介绍了如何在iPad应用程序上禁用横向取向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个全新的单视图iOS通用Swift应用程序.然后,我在应用程序设置中未选中左横向"和右横向".我在iPhone上运行它,万岁,无论我如何旋转手机,它都保持纵向模式.然后我在iPad上运行它,然后旋转到任何东西.甚至倒置人像模式(首先未启用)?我是唯一经历过此事的人吗?当我使用Command +箭头键旋转时,iPad模拟器中也会发生这种情况.

我还尝试将以下内容添加到ViewController.swift中,并得到相同的结果.

override func shouldAutorotate() -> Bool {
    return false
}

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
    return UIInterfaceOrientationMask.Portrait
}

在iPad上实际上没有办法禁止旋转肖像吗?

解决方案

它完美地工作.不需要为此编写代码.

首先选择项目,然后进入第一个标签常规".

现在,在部署信息"部分中选择设备"选项为 iPad ,然后在其中选择设备方向. >

完成后,将其选择为通用设备,并将设备方向设置为纵向..模式,并从横向模式中删除复选标记.

现在,在iPad上运行您的应用程序,然后检查一下.我希望它能解决.

I created a completely new, single-view iOS universal Swift app. Then, I unchecked "Landscape Left" and "Landscape Right" in the app settings. I ran it on my iPhone, and hooray, it stays in portrait mode no matter how I rotate my phone. Then I ran it on my iPad, and it rotates to anything. Even upside-down portrait mode, which wasn't enabled in the first place? Am I the only experiencing this? This happens in the iPad simulator as well when I rotate with command+arrow key.

I also tried adding the following to ViewController.swift, and got the same result.

override func shouldAutorotate() -> Bool {
    return false
}

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
    return UIInterfaceOrientationMask.Portrait
}

Is there no way to actually disable rotating away from portrait on iPad?

解决方案

Its work perfectly. Dont need to write code for it.

First select project and then go in first tab "General".

Now select "Devices" option in Deployment info section is iPad and in that down select Device orientation .. In which remove checkmark from landscape Left, Right option

After done select it back device as universal and set device orientation as portrait..mode and remove check mark from landscape mode.

Now run your app in iPad and check that things. I hope it will be resolved.

这篇关于如何在iPad应用程序上禁用横向取向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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