iOS如何处理设备方向变化
2010-12-19 07:19:19 来源:WEB开发网In an iOS application, the window object does much of the work associated with changing the current orientation. However, it works in conjunction with the application’s view controllers to determine whether an orientation change should occur at all, and if so, what additional methods should be called to respond to the change. Specifically, it works with the view controller whose root view was most recently added to, or presented in, the window. In other words, the window object works only with the frontmost view controller whose view was displayed using one of the mechanisms described in “Presenting a View Controller’s View.”
The actual rotation process proceeds along one of two paths depending on the implementation of the associated view controller. The most common path is to perform a one-step rotation but view controllers can also support a two-step rotation if it provides a better experience. The one-step rotation process is available in iOS 3.0 and later and is preferred because it is more efficient than the two-step process. The choice as to which path is taken is dependent on your view controller subclass and which methods you override. If you override any the methods associated with the one-step process, the window object uses that process; otherwise, it uses the two-step process.
Regardless of which rotation process is used, methods of the view controller are called at various stages of the rotation to give the view controller a chance to perform additional tasks. You might use these methods to hide or show views, reposition or resize views, or notify other parts of your application about the orientation change. Because your custom methods are called
更多精彩
赞助商链接