willAnimateRotationToInterfaceOrientation: duration: deprecated

After iOS 8 willAnimateRotationToInterfaceOrientation is no longer supported. After some experimenting I found that a drop-in replacement for:

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration {

     ... code



- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
    [coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context)

     ... code

     } completion:^(id<UIViewControllerTransitionCoordinatorContext> context)

    [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];

In case it isn’t clear, replace the method and then after your existing code, paste in the completion code and call super.

Leave a Reply

You must be logged in to post a comment.

Well Golly

Atheism Plus

Buy from Amazon