2012-09-26 58 views
2

我开发了使用游戏中心的IOS 5应用程序。现在我想让我的代码在IOS 6上运行。因此,我让应用程序支持横向和纵向两种方向,以便在弹出游戏中心登录屏幕时不会崩溃。但之后,我的主视图控制器不能以横向视图开始。相反,当我进一步观察时,它会以横向打开,然后当我回来时,主视图会在横向打开。但首页并未打开到横向模式。在xcode 4.5中设置横向模式的方向GM IOS 6

下面是代码:

- (BOOL)shouldAutorotate 
{ 
    return YES; 
} 

-(NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskLandscape; 
} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 
{ 
    return UIInterfaceOrientationLandscapeLeft; 
} 

这些都是我在家里视图使用IOS 6

+0

你是否支持项目plist文件中的所有方向? – AppleDelegate

+0

@AppleDelegate - 仅支持两种风景方向。 – NiKKi

+0

您的homeViewController是UINavigationController的根视图控制器吗? – rocky

回答

5

添加这种方法在应用程序委托,以支持所需方向的IOS 6 ..

代表
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window 

{ 
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
     return UIInterfaceOrientationMaskAll; 
    else /* iphone */ 
     return UIInterfaceOrientationMaskAllButUpsideDown; 
} 

和clases的其余部分使用这些delagates为导向的IOS 6

- (BOOL)shouldAutorotate 
{ 

return YES; 
} 

-(NSUInteger)supportedInterfaceOrientations 

{ 
return UIInterfaceOrientationMaskLandscape; 

} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 
{ 
    return UIInterfaceOrientationLandscapeLeft; 
} 
+0

你能解释第一个代码应该做什么,第二个更具体的例子是“iOS 6的类”吗?我怀疑你的意思是“意见”,但还没有尝试过。 – Danny

+0

是的。我的意思是。 – NiKKi