iOS如何处理设备方向变化
2010-12-19 07:19:19 来源:WEB开发网The window calls the view controller’s didAnimateFirstHalfOfRotationToInterfaceOrientation:method.
Container view controllers forward this message to the currently displayed custom view controller.
The window calls the view controller’swillAnimateSecondHalfOfRotationFromInterfaceOrientation:duration: method.
Container view controllers forward this message to the currently displayed custom view controller.
The window performs the second half of the rotation.
By the end of this rotation, the autoresizing behaviors for all views have been applied and the views are in their “final” position.
The window calls the view controller’s didRotateFromInterfaceOrientation: method.
Container view controllers forward this message to the currently displayed custom view controller. You can use this method to show views, reposition or resize views, or make other changes once the rotation has finished.
Figure 2-8 shows a visual representation of the preceding steps. Along with each step, it shows how the view would appear to the user.
Figure 2-8 Processing a two-step interface rotationCreating an Alternate Landscape Interface
If you want to present the same data differently based on whether a device is in a portrait or landscape orientation, the way to do so is using two separate view controllers. One view controller should manage the display of the data in the primary orientation (typically portrait) while the other manages the display of the data in the alternate orientation. Using two view controllers is simpler and more efficient than making major changes to your view hierarchy each time the orientation changes. It allows each view controller to focus on the presentation of data in one orientation and to manage things accordingly. It
更多精彩
赞助商链接