Iphone ios 6中的定向问题

Iphone ios 6中的定向问题,iphone,ios6,Iphone,Ios6,我在通用应用程序中工作,该应用程序在ios 5之前运行良好,但在ios 6中存在定位问题。我的应用程序仅处于纵向模式。问题是,当我的ipad处于横向模式时,如果我启动应用程序,方向不会变为protrait。因此,请帮我编写一些代码,以便在应用程序启动之前,我强制我的应用程序处于protrait模式,这与设备的方向无关,因为苹果改变了管理UIViewController方向的方式。在Ios6或Ios6容器中,处理方式不同。在Ios6容器(如UINavigationController)中,不要咨询

我在通用应用程序中工作,该应用程序在ios 5之前运行良好,但在ios 6中存在定位问题。我的应用程序仅处于纵向模式。问题是,当我的ipad处于横向模式时,如果我启动应用程序,方向不会变为protrait。因此,请帮我编写一些代码,以便在应用程序启动之前,我强制我的应用程序处于protrait模式,这与设备的方向无关,因为苹果改变了管理UIViewController方向的方式。在Ios6或Ios6容器中,处理方式不同。在Ios6容器(如UINavigationController)中,不要咨询其子容器以确定是否应自动旋转。默认情况下,应用程序和视图控制器支持的界面方向在iPad习惯用法中设置为UIInterfaceOrientationMaskAll,在iPhone习惯用法中设置为UIInterfaceOrientationMaskAllButUpsideDown。因此,默认情况下,设备的方向会发生变化

所以需要执行一些步骤

1-从这里设置方向

2-将此代码放入添加到RootViewController的FirstViewController中

  @implementation UINavigationController (RotationIn_IOS6)
   //Here UINavigationController is the RootViewController added To the Window

 -(BOOL)shouldAutorotate
{
return [[self.viewControllers lastObject] shouldAutorotate];
}

 -(NSUInteger)supportedInterfaceOrientations
{
   return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}

 - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
     return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
}

@end
**在IOS6中引入的ViewController中放置以下方法,以允许进行安装更改**

  - (BOOL)shouldAutorotate
 {

   return NO;

  }

/*Return the Number of Oreintation going to supported in device*/

 - (NSUInteger)supportedInterfaceOrientations
  {
return  (UIInterfaceOrientationMaskPortrait |     UIInterfaceOrientationMaskPortraitUpsideDown );

 }

 // Returns interface orientation masks.

  - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
  {
      return  (UIInterfaceOrientationPortrait | UIInterfaceOrientationPortraitUpsideDown      ) ;

 }

这是因为苹果改变了管理UIViewController方向的方式。在Ios6或Ios6容器中,处理方式不同。在Ios6容器(如UINavigationController)中,不要咨询其子容器以确定是否应自动旋转。默认情况下,应用程序和视图控制器支持的界面方向在iPad习惯用法中设置为UIInterfaceOrientationMaskAll,在iPhone习惯用法中设置为UIInterfaceOrientationMaskAllButUpsideDown。因此,默认情况下,设备的方向会发生变化

所以需要执行一些步骤

1-从这里设置方向

2-将此代码放入添加到RootViewController的FirstViewController中

  @implementation UINavigationController (RotationIn_IOS6)
   //Here UINavigationController is the RootViewController added To the Window

 -(BOOL)shouldAutorotate
{
return [[self.viewControllers lastObject] shouldAutorotate];
}

 -(NSUInteger)supportedInterfaceOrientations
{
   return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}

 - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
     return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
}

@end
**在IOS6中引入的ViewController中放置以下方法,以允许进行安装更改**

  - (BOOL)shouldAutorotate
 {

   return NO;

  }

/*Return the Number of Oreintation going to supported in device*/

 - (NSUInteger)supportedInterfaceOrientations
  {
return  (UIInterfaceOrientationMaskPortrait |     UIInterfaceOrientationMaskPortraitUpsideDown );

 }

 // Returns interface orientation masks.

  - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
  {
      return  (UIInterfaceOrientationPortrait | UIInterfaceOrientationPortraitUpsideDown      ) ;

 }

ViewController.m
中,必须定义支持的方向。在IOS 6中,这是处理支持的方向的方法

- (NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskAll;
}
UIInterfaceOrientationMaskAll
意味着它将支持
视图的所有方向


另外,请阅读
ViewController.m中的Apple文档-

,您必须定义支持的方向。在IOS 6中,这是处理支持的方向的方法

- (NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskAll;
}
UIInterfaceOrientationMaskAll
意味着它将支持
视图的所有方向


同时阅读苹果文档-

首先,我们必须在目标->摘要中设置支持的方向

在iOS6.0中,不推荐使用shouldAutorotateToInterfaceOrientation方法。因此,我们必须使用shouldAutorotate方法来代替此方法


使用支持接口方向的方法,我们必须设置我们想要的方向,如UIInterfaceOrientationMaskAll如果我们想要所有方向,我们首先必须在Targets->Summary中设置支持的方向

在iOS6.0中,不推荐使用shouldAutorotateToInterfaceOrientation方法。因此,我们必须使用shouldAutorotate方法来代替此方法


使用支持接口方向的方法,我们必须设置我们想要的方向,如UIInterfaceOrientationMaskAll如果我们想要所有方向

你能把didFinishLaunchingWithOptions方法的代码放在Appdelegate类中吗你为IOS 6方向写了什么?你能把Appdelegate类中的FinishLaunchingWithOptions方法为IOS 6定向写了什么?