【问题标题】:iPad app interface orientation changed after launch of aplicaiton启动应用程序后 iPad 应用程序界面方向更改
【发布时间】:2013-11-20 01:41:29
【问题描述】:

我正在开发应用程序。应用程序的方向是横向的,但是在应用程序运行后应用程序的界面方向会改变界面并旋转。以正确的方式(横向)显示初始屏幕。 我正在使用 ios7 该应用程序是 ios5 的代码我认为有一些已弃用的 api 问题,例如调用 shouldAutorotateToInterfaceOrientation 机器人,因为这在最新的 ios 中不再可用

【问题讨论】:

  • 您想以横向显示此视图吗?
  • 是的 deepak,因为您看到我的应用程序方向已旋转,但模拟器处于横向模式。我的应用也适用于横向
  • 在属性检查器中检查 XIB 视图的方向..

标签: ios ipad ios7 orientation uiinterfaceorientation


【解决方案1】:

如果您希望我们所有的导航控制器都尊重顶视图控制器,您可以使用一个类别,这样您就不必经历并更改一堆类名。

 @implementation UINavigationController (Rotation_IOS6)

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

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

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

@end

正如一些 cmets 所指出的,这是解决问题的快速方法。更好的解决方案是子类 UINavigationController 并将这些方法放在那里。子类也有助于支持 6 和 7。

【讨论】:

  • 我的应用仅适用于 iOS 7
【解决方案2】:

你必须在构建时设置 orintatoin 看图片。

它会解决你的问题。

【讨论】:

    【解决方案3】:

    试试这个:

    - (BOOL)shouldAutorotate
    {
        return YES;
    }
    
    - (NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
    }
    

    编辑:

    见附件link,可能对你有帮助。

    【讨论】:

    • 这是您的第一个视图吗?
    【解决方案4】:

    我找到解决方案,我的想法是。 第一步 通过创建一个类别覆盖我的 UInavigationcontroller

    第二步 代替 [self.window addSubview:[navigationController 视图]]; //旧

    有 [self.window setRootViewController:navigationController]; //新

    【讨论】:

      【解决方案5】:

      在你的 Appdelegate.m 中使用它

      - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
      {
          NSLog(@"Interface orientations");
          if([[UIDevice currentDevice]userInterfaceIdiom]==UIUserInterfaceIdiomPad ){
      
              return UIInterfaceOrientationMaskLandScape;
          }
          else{
              return UIInterfaceOrientationMaskPortrait;
          }
      }
      

      它帮助了我..

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-03-25
        • 1970-01-01
        • 2011-08-03
        • 2011-04-03
        • 1970-01-01
        • 2016-07-14
        • 1970-01-01
        相关资源
        最近更新 更多