duration of willAnimateRotationToInterfaceOrientation


#1

I read in the book that the duration argument of willAnimateRotationToInterfaceOrientation tells how long that animation will take, and willRotateToInterfaceOrientation: will not animate views. However, I noticed that the latter still animated views and the comment on duration was different in apple doc like below, though the meaning of it was not very clear to me.

It seems that each method is called in different context like from within animation block mentioned below.


#2

If you add code in willRotateToInterfaceOrientation:duration:, the changes will be applied immediately when the rotation begins. As an example, I just changed the backgroundColor of a view, and the change happens instantaneously when the rotation begins.

The same change in willAnimateRotationToInterfaceOrientation:duration: will cause the change (the background color in my example), to animate over the duration of the rotation. Gradually instead of instantaneously.

Here is the code I used:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    // Uncomment the following line to see the instantaneous change
//    self.view.backgroundColor = [UIColor redColor];
}

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    // Uncomment the following line to see the animated change
//    self.view.backgroundColor = [UIColor redColor];
}