在xcode 4.5 GM IOS 6中将方向设置为横向模式 [英] Set orientation to landscape mode in xcode 4.5 GM IOS 6

查看:101
本文介绍了在xcode 4.5 GM IOS 6中将方向设置为横向模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用游戏中心开发了IOS 5应用程序。现在我想让我的代码在IOS 6上运行。所以我让我的应用程序支持方向,即横向和纵向,以便在游戏中心登录屏幕弹出时不会崩溃。但在那之后,我的家庭视图控制器不会在横向视图中启动。相反,当我进入另一个视图时,它会在横向打开,然后当我回来时,主视图将以横向打开。但是主视图第一次没有打开横向模式。

I developed IOS 5 application using game center. Now I want my code to run on IOS 6. So I have let my application to support both orientation i.e landscape and portrait so that it does not crashes when game center login screen pops up. But after that, my home view controller does not starts in landscape view. Instead when I go to a further view, it opens in landscape, and then when i come back, then the home view opens in landscape. But home view does not opens to landscape mode for the first time.

以下是代码:

- (BOOL)shouldAutorotate
{
  return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{
  return UIInterfaceOrientationMaskLandscape;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
  return UIInterfaceOrientationLandscapeLeft;
}

这些是我在IOS 6的主视图中使用的代表。

These are the delegates I use in home view for IOS 6.

推荐答案

在您的应用代表中添加此方法,以支持IOS 6的所需方向..

Add this method in your app delegate to support desired orientation for IOS 6..

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

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

并使用这些delagates来定义IOS 6的其余部分。

and use these delagates for orientation in rest of clases for IOS 6.

- (BOOL)shouldAutorotate
{

return YES;
}

-(NSUInteger)supportedInterfaceOrientations

{
return UIInterfaceOrientationMaskLandscape;

}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
  return UIInterfaceOrientationLandscapeLeft;
}

这篇关于在xcode 4.5 GM IOS 6中将方向设置为横向模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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