【问题标题】:Device orientation will change instead of has changed设备方向将改变而不是已经改变
【发布时间】:2012-06-15 18:33:55
【问题描述】:

有什么方法可以在设备方向动画完成之前执行代码?

现在我将自己添加为 UIDeviceOrientationDidChangeNotification 的观察者

但是我需要在更改实际发生之前完成我的代码,而不是之后。

【问题讨论】:

    标签: iphone xcode ipad uideviceorientation


    【解决方案1】:

    查看文档:)

    响应视图轮换事件 –

    willRotateToInterfaceOrientation:duration:

    willAnimateRotationToInterfaceOrientation:duration:

    didRotateFromInterfaceOrientation:

    http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIViewController_Class/Reference/Reference.html

    【讨论】:

    • 我没有使用 UIViewController。这就是为什么我要尝试我们的 NSNotification 中心
    • 抱歉。然后我建议这个 SO 答案。 stackoverflow.com/questions/1160620/…
    • 是的……我基本上就是这么做的。并使用了视图 setNeedsLayout。这样我就可以更改字段并更新显示。
    【解决方案2】:

    尝试用这个方法改一下:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        // Return YES for supported orientations
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多