简体   繁体   English

UINavigation视图和UITabbar视图在iOS6中不起作用?

[英]Upside down orientation not working in iOS6 for UINavigation view and UITabbar view?

I created an app in ios 6 with navigation view.Also I have set all orientation options in the application summary and even used the 我在ios 6中创建了一个带导航视图的应用程序。我也在应用程序摘要中设置了所有方向选项,甚至使用了

 -(BOOL) shouldAutoRotate

and

-(NSUInteger) supportedInterfaceOrientaion

methods in my view controller.when I run my app orientation works fine except upside-down.What should I do to also support upside-down. 在我的视图控制器中的方法。当我运行我的应用程序方向工作正常,除了颠倒。我应该做什么也支持倒置。

I also facing the same problem when I add UITabBar controller. 当我添加UITabBar控制器时,我也面临同样的问题。

Please share your ideas. 请分享您的想法。

Thank you 谢谢

Hai I have found solution for my problem Hai我找到了解决问题的方法

Solution: For the app which consist UINavigation controller, just I created a category for UINavigation Controller class and I defined these methods 解决方案:对于包含UINavigation控制器的应用程序,我只为UINavigation Controller类创建了一个类别,并定义了这些方法

-(BOOL) shouldAutorotate{
    return YES;
}

-(NSUInteger) supportedInterfaceOrientations{

    return UIInterfaceOrientationMaskAll;
}

After adding this, all orientation were supported in my app. 添加后,我的应用程序支持所有方向。

The same, I done for UITabBar Controller also.This too worked for me by creating category for UITabBar Controller. 同样,我也为UITabBar Controller做了。通过为UITabBar Controller创建类别,这也为我工作。

Thank you. 谢谢。

Phone apps traditionally don't support upside down (why would you hold the phone upside down?) - the default project will support portrait and both landscape options, but not upside down. 手机应用程序传统上不支持颠倒(为什么你会把手机颠倒?) - 默认项目将支持肖像和横向选项,但不是颠倒。

Change this in the project info viewer in Xcode and you should be fine. 在Xcode的项目信息查看器中更改此项,您应该没问题。 There is a visual representation of the supported orientations, and upside down will be unselected. 可以直观地显示支持的方向,并且将取消选择颠倒。

I think the solution of NSUserDefault is incomplete: 我认为NSUserDefault的解决方案不完整:

From: https://developer.apple.com/library/ios/qa/qa1688/_index.html 来自: https//developer.apple.com/library/ios/qa/qa1688/_index.html

Note: You should always prefer subclassing to categories when modifying rotation behavior for UIKit classes such as UINavigationController. 注意:在修改UIKit类(如UINavigationController)的旋转行为时,您应该始终更喜欢子类化到类别。 Because other classes may depend on the existing behavior of the UIKit container view controllers, the changes introduced by a category may cause unexpected behavior. 由于其他类可能依赖于UIKit容器视图控制器的现有行为,因此类别引入的更改可能会导致意外行为。

So I think the best solution is to create a subclass and to add: 所以我认为最好的解决方案是创建一个子类并添加:

-(BOOL) shouldAutorotate{
     return YES;
}

-(NSUInteger) supportedInterfaceOrientations{

     return UIInterfaceOrientationMaskAll;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM