简体   繁体   English

使用UIDeviceOrientation更改通知而不是viewillTransistionToSize

[英]Using UIDeviceOrientation change notification instead of viewillTransistionToSize

I have managed to support Portrait and Landscape orientations for my app. 我设法为我的应用程序支持纵向和横向方向。

However, my implementation is based on UIDeviceOrientationChangeNotification . 但是,我的实现基于UIDeviceOrientationChangeNotification I do not use viewillTransistionToSize 我不使用viewillTransistionToSize

Offical Apple sample code for AlternateViews does use notification based approach. Apple的AlternateViews官方示例代码确实使用基于通知的方法。 So I assumed it should be fine. 所以我认为应该没问题。

  • Is there any significant advantage/disadvantage of using one over another? 相较于另一种,有什么明显的优点/缺点吗?
  • Would it ever happen that my app will not get deviceOrientationChangenotification ? 我的应用程序将无法获得deviceOrientationChangenotification吗?

Please clarify. 请澄清。

I am using a combination of both. 我正在使用两者的组合。 But to me it looks like viewillTransistionToSize gives more control as you can execute code 但是在我看来,viewillTransistionToSize可以提供更多控制权,因为您可以执行代码

  • before rotation begins 旋转开始之前
  • during rotation 旋转期间
  • after rotation 旋转后

while in case of Notification you only execute code after rotation. 而在使用Notification的情况下,您只能在轮换后执行代码。

Not sure but I found this thru experimentation and not thru docs. 不确定,但是我是通过实验而不是通过文档发现的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM