3

So I have a viewcontroller who on a button click presents a modal. So The view controller that is presenting the modal only allows portrait animation. While the modal should allow all the rotation types. So if I present the modal with default animation the rotation works as expected e.g the view controller that is presenting the modal stays in portrait and the modal can rotate freely. So I wanted to use a custom transition to present and dismiss the modal controller. This is snippet which is used to present the modal.

SecondViewcontroller *sec = [[SecondViewcontroller alloc] initWithNibName:nil bundle:nil];
sec.transitioningDelegate = self;
sec.modalPresentationStyle = UIModalPresentationCustom;
[self presentViewController:sec animated:YES completion:nil];

So I set up the UIViewControllerTransitioningDelegate methods for presenting and dismissing modals to return my Animator object. So now when I present the modal it now does this custom animation and everything appears to work. Except now the modal can no longer rotate and is stuck in portrait. So I decided to try and see if it was something odd with the animator causing it. So in the UIViewControllerTransitioningDelegate methods that return the custom Animator object I set them to return nil e.g use the default system animation. But no luck, it seems once I set

sec.modalPresentationStyle = UIModalPresentationCustom;

autorotation no longer works.

Jayyyyy
  • 733
  • 2
  • 6
  • 12
  • [Check my answer here](http://stackoverflow.com/a/27144889/312312) The part where I change the `modalPresentationStyle` back after the transition is completed. It might help you – Lefteris Feb 06 '15 at 10:09
  • So this allows the modal to start rotating correctly but when the modal is dismissed. The controller that presented the modal is now in landscape orientation even though it only supports portrait. But when not using the UIModalPresentationCustom and the custom transitions the controller who presented the modal would always return to portrait orientation when the modal was dismissed. – Jayyyyy Feb 06 '15 at 11:13
  • I also tried changing the modalpresentationStyle in the completion block and it works for me on iOS 9, but it does not on iOS 8.. Any ideas? – JarnoV May 25 '16 at 15:26

0 Answers0