Can't change the presentation and transition styles of modal views in Xcode (iPad)

Dan Cearnau picture Dan Cearnau · Oct 12, 2011 · Viewed 15.8k times · Source

I'm currently having some trouble with modal views and popovers. It might be the same problem, but I'm not sure.

The problem I'm having with modal views is that I can't change the animation or transition style. For instance, I write

self.modalPresentationStyle = UIModalPresentationPageSheet;
self.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:IpModal animated:YES];

but the modal view still appears full screen with its original transition style.

Also, the problem I'm having with popovers is pretty similar. Even though I call the dismissPopover:animated: method with "NO" as the parameter, the transition is still animated.

Thanks in advance.

Answer

jrturton picture jrturton · Oct 12, 2011

modalPresentationStyle and modalTransitionStyle apply to the view controller that is to be presented modally, not the controller doing the presenting.

Your code should be

IpModal.modalPresentationStyle = UIModalPresentationPageSheet;
IpModal.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:IpModal animated:YES];