加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

如何在iPhone应用程序上仅支持纵向模式

发布时间:2020-12-14 18:57:06 所属栏目:百科 来源:网络整理
导读:我正在开发的iPhone应用程序中有一个奇怪的问题.我希望我的应用程序仅支持纵向模式,但出于某种原因我不能这样做(设备和模拟器). 为了仅支持肖像模式我做了如下: 在Xcode的TARGET摘要部分,我只选择了肖像. 我的所有ViewControllers都实现了shouldAutorotateT
我正在开发的iPhone应用程序中有一个奇怪的问题.我希望我的应用程序仅支持纵向模式,但出于某种原因我不能这样做(设备和模拟器).

为了仅支持肖像模式我做了如下:

>在Xcode的TARGET摘要部分,我只选择了肖像.
>我的所有ViewControllers都实现了shouldAutorotateToInterfaceOrientation

但正如我所说它不起作用,奇怪的结果是该应用程序支持所有方向(纵向,颠倒,左侧景观,右侧景观).
有任何想法吗?

这个我如何实现shouldAutorotateToInterfaceOrientation

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
     // Return YES for supported orientations
     NSLog(@"Checking orientation %d",interfaceOrientation);
     return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

我刚刚注意到,当我旋转手机时,我收到以下消息:

“Two-stage rotation animation is deprecated. This application should
use the smoother single-stage animation.”

这是什么意思?

解决方法

屏幕上可以有多个ViewControllers. UITabBarController本身就是一个UIViewController,它只在它选择的情况下将shouldAutorotateToInterfaceOrientation:请求传递给viewControllers.默认实现执行此操作,但如果您将其子类化,则XCode生成的代码(从iOS 5.1开始)不会.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读