2012-09-19 46 views
7

几分钟前,我设置了XCode 4.5和iOS6模拟器。 我的应用程序支持iPhone的所有方向, 肖像底部和顶部主页按钮,左右风景。iOS6模拟器不能正常工作的热门按钮纵向方向

那么,我把它放到.plist中,因为它是iOS6所需要的,旧的shouldRotateTo ...方法仍然会返回YES。

但在模拟器中,应用程序是而不是旋转到肖像顶部主页按钮。

为什么?这是故意的吗?设备上的工作是否正确?

谢谢。

回答

18

好的, 现在我自己找到了答案。

如果推入UINavigationViewController这是不够的

- (BOOL)shouldAutorotate { 

    return YES; 
} 

- (NSUInteger)supportedInterfaceOrientations { 

    return UIInterfaceOrientationMaskAll; 
} 

在你的视图控制器。 UINavigationViewController也必须有这些方法。 最好是通过在UINavigationViewController上有一个小类别来做到这一点。

这是我UINavigationController-Rotation.h

@interface UINavigationController (Rotation) 
@end 

和我的UINavigationController-Rotation.m:

#import "UINavigationController-Rotation.h" 

@implementation UINavigationController (Rotation) 

#pragma From UINavigationController 

- (BOOL)shouldAutorotate { 

    BOOL result = self.topViewController.shouldAutorotate; 

    return result; 
} 

- (NSUInteger)supportedInterfaceOrientations { 

    NSUInteger result = self.topViewController.supportedInterfaceOrientations; 

    return result; 
} 

#pragma - 

@end 

感谢您帮助我!

+0

感谢您分享答案.. –

1

我认为你的viewControllers将会返回默认值,但这些值都是倒过来的。您需要实现:

-(NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskAll; 
} 

对于所有您希望支持所有方向的viewControllers。

+0

不起作用。还设置所有界面方向在plist中,从ViewController返回YES - (BOOL)shouldAutorotate和... MaskAll from AppDelegate's - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window。 – Christoph

+0

在iPad模拟器上按预期工作。可能是iPhone版本中的错误? – Christoph

+0

我将不得不阅读新的文档。我目前的期望是将其设置在.plist文件中,并在视图控制器中返回maskAll应该这样做。我记得还提到从appDelegate返回。这可能是一块失踪。 –

2

iPhone上iOS6的默认行为是没有颠倒的方向。

from UIViewController Class Reference: The default values for a view controller’s supported interface orientations is set to UIInterfaceOrientationMaskAll for the iPad idiom and UIInterfaceOrientationMaskAllButUpsideDown for the iPhone idiom.

你可以看到这种行为也是在Safari或地图。

我试图用UIInterfaceOrientationMaskAll覆盖这个,就像Dean说的,但没有效果。 我决定不再使用颠倒模式了,因为它是一种用户界面指南,我喜欢遵循而不是混淆用户。

+0

由于iPhone 3GS-4S上的麦克风放置,我并不着急,并且真的想要颠倒支持。 – Christoph

0

万一别人甚至以下Christoh的回答后,谁是仍然有问题:

我只注意到这些项目的plist拥有iPad和iPhone(支持的界面取向(新iPad)和支持的界面取向(iPhone单独条目) )。

希望有所帮助。