如何锁定纵向方向以仅在ios 7中查看 [英] how to lock portrait orientation for only view in ios 7

查看:68
本文介绍了如何锁定纵向方向以仅在ios 7中查看的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为Iphone和Ipad创建了一个应用程序,该应用程序由两个带有导航控制器的主视图组成.导航控制器被插入tabBar控制器中. 我想将主视图锁定为纵向,并且仅导航控制器的子视图会触发对Partrait和Landscape的可能性排列. 是否有可能? 我该怎么办?

I have created an application for Iphone and Ipad that is composed from two main views with navigation controller. The navigation controllers are inserted into tabBar controller. I would like lock the main views to Portrait orientation and only a subview of a navigation controller trigger the possibility orintation to Partrait and Landscape. Is it possible? How Can I do?

谢谢

推荐答案

到目前为止给出的两个答案都是错误的.

Both answers given so far are wrong.

这是您的工作:

确保在info.plist文件的受支持方向列表中列出纵向和横向. (默认的应用模板包括iPad的所有方向,以及iPhone倒置的所有方向,这可能就是您想要的.)

Make sure you list portrait and landscape in the list of supported orientations in your info.plist file. (The default app templates include all orientations for iPad, and all but portrait upside-down for iPhone, which is probably what you want.)

您要在要限制为纵向的视图控制器中实现方法supportedInterfaceOrientations::

You want to implement the method supportedInterfaceOrientations: in the view controllers that you want to limit to portrait:

- (NSUInteger)supportedInterfaceOrientations
{
  return UIInterfaceOrientationMaskPortrait;
} 

任何包含该代码的视图控制器将仅支持纵向.所有其他人将支持您的info.plist中列出的所有方向.

Any view controllers that include that code will only support portrait. All others will support all the orientations listed in your info.plist.

仅当您支持6.0之前的操作系统版本时,才需要较早的方法shouldAutorotateToInterfaceOrientation:.

The older method shouldAutorotateToInterfaceOrientation: is only needed if you support OS versions prior to 6.0.

如果有时可能返回NO(不旋转),则还只需要实现方法shouldAutorotate.)

You also only need to implement the method shouldAutorotate if you might return NO (don't rotate) sometimes.)

这篇关于如何锁定纵向方向以仅在ios 7中查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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