iOS如何处理设备方向变化
2010-12-19 07:19:19 来源:WEB开发网The following sequence of events occurs during a two-step rotation:
The window detects that a change in the device orientation has occurred.
The window looks for an appropriate view controller and calls itsshouldAutorotateToInterfaceOrientation: method to determine if it supports the new orientation.
Container view controllers may intercept this method and use their own heuristics to determine whether the orientation change should occur. For example, the tab bar controller allows orientation changes only if all of its managed view controllers support the new orientation.
If the new orientation is supported, the window calls the view controller’swillRotateToInterfaceOrientation:duration: method.
Container view controllers forward this message to the currently displayed custom view controller. You can use this method to hide views or make other changes to your view layout before the interface is rotated.
The window calls the view controller’swillAnimateFirstHalfOfRotationToInterfaceOrientation:duration: method.
Container view controllers forward this message to the currently displayed custom view controller. You can use this method to hide views or make other changes to your view layout before the interface is rotated.
The window performs the first half of the rotation.
This causes the bounds of each view in the view hierarchy to be adjusted based on its autoresizing behaviors. Although most rotations involve moving from portrait to landscape mode (and thus rotating 45 degrees to the halfway point), it is possible to rotate from a landscape left to landscape right orientation or from a portrait to upside down portrait orientation. In these latter cases, the
更多精彩
赞助商链接