为什么iPhone 5不会旋转到upsideDown [英] why iPhone 5 doesn't rotate to upsideDown

查看:470
本文介绍了为什么iPhone 5不会旋转到upsideDown的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将新方法添加到我的代码中,如苹果iOS 6 Documentations所述,但在iPhone 5上,应用程序不会颠倒过来。只有景观方式。

i added the new methods to my code like described at apples iOS 6 Documentations but on the iPhone 5 the App doesn't rotate to upside down. Only the to landscape Ways.

这里我的代码来自rootViewController:

Here my Code from the rootViewController:

- (NSUInteger)supportedInterfaceOrientations{
    NSLog(@">>> Entering %s <<<", __PRETTY_FUNCTION__);
    return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft |
            UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown);
}
- (BOOL)shouldAutorotate{
    NSLog(@">>> Entering %s <<<", __PRETTY_FUNCTION__);
    return YES;
}

我还尝试了UIInterfaceOrientationMaskAll但没有变化。奇怪的是,我的带有iOS6的iPhone 4使用相同的代码完全颠倒了o。

i tryed also "UIInterfaceOrientationMaskAll" but no changes. The Strange is, my iPhone 4 with iOS6 does totate o upside down with the same code.

任何想法?

推荐答案

IOS 6使用默认方向<$用于iPad的c $ c> UIInterfaceOrientationMaskAll 和用于iPhone的 UIInterfaceOrientationMaskAllButUpsideDown 。如果您希望iPhone上的ViewControllers旋转到所有方向,包括UpsideDown,您必须添加iOS 6方法:

IOS 6 uses default Orientation UIInterfaceOrientationMaskAllfor iPad and UIInterfaceOrientationMaskAllButUpsideDownfor iPhone. If you want your ViewControllers on the iPhone to rotate to ALL orientations including UpsideDown you must add the iOS 6 method:

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}

到所有视图控制器。如果你已经完成了这个并且它没有工作那么我打赌你使用TabViewController或NavigationController,其中一些视图没有返回这个。所有ViewControllers都必须为它们中的任何一个返回它以支持它。

to all view controllers. If you've done this and it is not working then I am betting your using a TabViewController or NavigationController where some of the views are NOT returning this. All ViewControllers must return this for ANY of them to support it.

或者你可以将一个Category添加到作为rootViewController的UITabViewController或NavigationController类并覆盖该方法。你这样做:

Alternatively you can add a Category to the UITabViewController or NavigationController class that is your rootViewController and override that method. You do that like so:

@interface UITabBarController (RotationAll)
    -(NSUInteger)supportedInterfaceOrientations;
@end

@implementation UITabBarController (RotationAll)
-(NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}
@end

这些是目前正在讨论的目前推荐的方法苹果工作人员论坛中的苹果工作人员论坛上说,不鼓励对UINavigationController进行子类化的早期文档是过时的,从iOS 6开始就可以这样做。

Also these are the currently recommended approaches now being discussed in Apple Developer Forums with Apple staff saying earlier documentation that discouraged sub classing of UINavigationController is out of date, and as of iOS 6 it is ok to do that.

这篇关于为什么iPhone 5不会旋转到upsideDown的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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