Search code examples
iosobjective-ciphoneanimationpresentviewcontroller

UIViewController presentViewController modal not animating in iOS7


Calling presentViewController:animated:completion: does not animate in iOS7. The view just instantly appears. Animation works properly in iOS8. The present method is called in three different places in my app and they all display this behavior. It happens on both device and simulator.

The subsequent call to dismissViewControllerAnimated:completion: animates properly in all iOS versions.

Code Structure

The view controller calling the present method is the root view controller of a UINavigationController, and this navigation controller is one of the viewControllers in a UITabBarController.

Each call is simple, and is triggered by a button press. Here is one of the cases:

GenreViewController *controller = [[GenreViewController alloc] init]; [self presentViewController:controller animated:YES completion:nil];

Attempted Fixes

  • Explicitly dispatching to the main thread
  • Calling [UIView setAnimationsEnabled:YES] before presentation
  • Adding a delay to displaying the controller (just to see what would happen)

In each case the behavior was unchanged.
Any help would be hugely appreciated!

UPDATE - FIX

It turns out that the UITabBarController had the modalPresentationStyle property being set to UIModalPresentationCurrentContext. This will not animate in iOS7, and you must use a presentation style of UIModalPresentationFullScreen instead.


Solution

  • It turns out that the UITabBarController had the modalPresentationStyle property being set to UIModalPresentationCurrentContext. This will not animate in iOS7, and you must use a presentation style of UIModalPresentationFullScreen instead.