开发者

What are the differences between the interface orientation delegate methods

开发者 https://www.devze.com 2022-12-24 13:26 出处:网络
anyone can tell differences among willRotateToInterfaceOrientation, willAnimateRotationToInterfac开发者_运维问答eOrientation,

anyone can tell differences among willRotateToInterfaceOrientation, willAnimateRotationToInterfac开发者_运维问答eOrientation, didRotateFromInterfaceOrientation,


iOS originally did all rotations in a two-step process. In iOS 3.0, a new/better one-step animation process was introduced. The methods you mention are called at different stages in rotation. Specifically,

willRotateToInterfaceOrientation:duration: is called whenever the view is going to rotate (using any rotation method), before any rotation is started. This method will be called on ANY version of iOS, ANY time a rotation is performed (on an actively-shown view)

willAnimateRotationToInterfaceOrientation:duration: is called during a one-step rotation operation, just before the animation is drawn. This will only be called on iOS 3.0+.

didRotateFromInterfaceOrientation: is called at the end of a rotation operation (using any rotation method), after the rotation is complete. This method will be called on ANY version of iOS, ANY time a rotation is performed (on an actively-shown view).

In practice, on any modern (3.0+) iOS, all three methods are sent to the view controller of the actively-shown view. The methods are called in the order listed:

willRotateToInterfaceOrientation:duration: first willAnimateRotationToInterfaceOrientation:duration: second, didRotateFromInterfaceOrientation: last

Note: iOS 5 deprecates the other rotation-notification methods (dealing with the two-step animation process), so these three are the only ones that should be used in new projects.


From the UIViewController Class Reference:

willRotateToInterfaceOrientation:duration:

Sent to the view controller just before the user interface begins rotating.


willAnimateRotationToInterfaceOrientation:duration:

Sent to the view controller before performing a one-step user interface rotation.


didRotateFromInterfaceOrientation:

Sent to the view controller after the user interface rotates.


The most significant difference I think is when method willRotateToInterfaceOrientation:duration: is called the self.view.bounds doesn't change but when method willAnimateRotationToInterfaceOrientation:duration: is called self.view.bounds has changed

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号