【问题标题】:Views do not rotate correctly视图无法正确旋转
【发布时间】:2011-10-21 06:31:42
【问题描述】:

我使用 IF 语句来检测设备的方向何时发生变化,当它发生变化时,会显示一个新视图,一个纵向,另一个横向。唯一的问题是,如果我从纵向旋转到横向,并且横向视图显示,它并没有完全旋转。它仍然是纵向的,与应有的位置相差 90 度。感谢您的帮助!

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {

    if (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
        //portrait

        self.view = portrait;


    } else {
        //landscape

        self.view = landscape;

    }

}

【问题讨论】:

    标签: iphone ios ipad view orientation


    【解决方案1】:

    Apple为此here提供了示例代码。

    【讨论】:

      【解决方案2】:

      您可以通过在 willRotateToInterfaceOrientation 期间存储目标方向来修复它,然后在 didRotateFromInterfaceOrientation 上推送您的新视图。

      【讨论】:

      • 好的,那我该怎么做呢?类似于 self.view = UIInterfaceOrientationPortrait || UIInterfaceOrientationPortraitUpsideDown 等?感谢您的帮助!
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-19
      • 1970-01-01
      相关资源
      最近更新 更多