Reputation: 8303
In iOS 8, when presenting a modal (lets say with a transparent background), we need to set the segue (or the modal) to use the presentation style of UIModalPresentationOverCurrentContext
. This is working as expected.
To accomplish the same thing for iOS 7, you instead, need to set the presenting view controller to have a modal presentation style of UIModalPresentationCurrentContext
. Here's where I'm having an issue. I present the modal with animation, but it doesn't animate. After it is presented, everything works fine, even animating the dismissal. Further, if I change the presentation style to UIModalPresentationFullScreen
, it animates correctly.
I've searched around and read other posts, but I can't find the cause of this or a solution.
Upvotes: 3
Views: 1195
Reputation: 149
ViewController *vcObj = [[ViewController alloc] initWithNibName:NSStringFromClass([ViewController class]) bundle:nil];
UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:vcObj];
if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {
navCon.providesPresentationContextTransitionStyle = YES;
navCon.definesPresentationContext = YES;
navCon.modalPresentationStyle = UIModalPresentationOverCurrentContext;
[self presentViewController:navCon animated:NO completion:nil];
}
else {
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[self presentViewController:navCon animated:NO completion:^{
[navCon dismissViewControllerAnimated:NO completion:^{
appDelegate.window.rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentViewController:navCon animated:NO completion:nil];
appDelegate.window.rootViewController.modalPresentationStyle = UIModalPresentationFullScreen;
}];
}];
}
Upvotes: 1