user141302
user141302

Reputation:

What are the differences between the interface orientation delegate methods

anyone can tell differences among willRotateToInterfaceOrientation, willAnimateRotationToInterfaceOrientation, didRotateFromInterfaceOrientation,

Upvotes: 1

Views: 2725

Answers (3)

dopcn
dopcn

Reputation: 4218

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

Upvotes: 1

Jeff Hay
Jeff Hay

Reputation: 2645

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.

Upvotes: 8

Shaggy Frog
Shaggy Frog

Reputation: 27601

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.

Upvotes: 3

Related Questions