iOS模拟器中UIViewController事件的顺序?
以下是错误还是功能?
我的测试应用程序有一个根 UIViewController
。它实现了 viewDidAppear:
和 willRotateToDeviceOrientation:
现在,iOS 模拟器已经在运行并且设置为 landscape。 如果我设置断点,我可以清楚地看到 viewDidAppear:
在 willRotateToDeviceOrientation:
之前被调用
,其结果是在 viewDidAppear:
中,宽度和视图的高度仍然不正确:宽度= 768,高度= 1024。 只有在 willRotateToDeviceOrientation:
之后它们才是正确的。
如果我退出模拟器并运行应用程序,模拟器将以纵向启动。只有 viewDidAppear:
会被触发,并且宽度 = 768,高度 = 1024 - 正如预期的那样。
为什么要调用 willRotateToDeviceOrientation:
?设备已经处于横向状态,并且它知道这一点,因为它根本不会触发旋转动画。
我是否应该在 willRotateToDeviceOrientation:
中重新配置视图的尺寸?
Is the follwing a bug or a feature?
My test app has one root UIViewController
. It implements viewDidAppear:
and willRotateToDeviceOrientation:
Now it happens that the iOS simulator is already running and is set to landscape.
If I put breakpoints, I can clearly see that viewDidAppear:
is called before willRotateToDeviceOrientation:
The consequence of this is that in viewDidAppear:
the width and height of the view are still incorrect: width = 768, height = 1024.
Only after willRotateToDeviceOrientation:
they are correct.
If I quit the simulator and run the app, the simulator will start in portrait. Only viewDidAppear:
will be triggered and the width = 768, the height = 1024 - as expected.
Why is the willRotateToDeviceOrientation:
called at all? The device is already in landscape and it knows that because it does not trigger a rotation animation at all.
Am I supposed to reconfigure my views' dimensions in willRotateToDeviceOrientation:
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论