Reputation: 653
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.
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];
[UIView setAnimationsEnabled:YES]
before presentationIn each case the behavior was unchanged.
Any help would be hugely appreciated!
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.
Upvotes: 2
Views: 3742
Reputation: 874
Can you check this :
GenreViewController *controller = [[GenreViewController alloc] init];
controller.view.backgroundColor = [UIColor whiteColor]; // or some color of your choice
[self presentViewController:controller animated:YES completion:nil];
And see if it works. As which I feel might be the problem while using UIViewController programatically
Upvotes: 0
Reputation: 653
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.
Upvotes: 1
Reputation: 2297
As per your comment
As per my knowledge this animation is not possible without NavigationController. If you have created all the things programatically then also you needs to create NavigationController programatically and have to assign one of ViewController as a root ViewController. Then going for presentViewController.
Make Global UINavigationController in appDelegate
and in didFinishLaunchingWithOptions
InitialViewController *initialVC = [[InitialViewController alloc] init];
self.navController = [[UINavigationController alloc] initWithRootViewController:initialVC];
self.window.rootViewController = self.navController;
[self.window makeKeyAndVisible];
And Then get your Appdelegate Navigation controller in specific ViewController where you want to make presentaion.
May be what you have created NavigationController is improper in Navigation Hierarchy.
Upvotes: 0
Reputation: 543
you may use this
GenreViewController *addController = [[GenreViewController alloc]
init];
UINavigationController *navigationController = [[UINavigationController alloc]
initWithRootViewController:addController];
[self presentViewController:navigationController animated:YES completion: nil];
Upvotes: 1