Search code examples
ioscocoa-touchuiviewcontrolleruiviewanimationtransition

UIViewController with Custom Transition; Lost After Modal Presentation


Scenario: one UIViewController uses a custom transition to present another VC. This VC does not take up the entire screen; it's appearing as a layer on top of the first. Everything here is working great.

Now the presented VC wants to show a UIImagePickerController — to take a photo. But once that controller is dismissed, the second VC is displayed as a full-screen view: the effects of the original transition have been lost.

I've borrowed someone else's demo code for UIViewController transitions to quickly demonstrate this effect. Once you add the partial-screen second VC and bring up the camera view, dismissing it leaves you with a full-screen second view.

I've been unable to find other folks having this issue, but its repeatability suggests a framework bug.

https://github.com/aaronvegh/CustomViewControllerTransition


Solution

  • Found the solution: you have to set a modalPresentationStyle property on the camera VC before showing it. In my instance I set it to UIModalPresentationCustom, and that resolved the issue: when the camera is dismissed, the underlying custom transition bounds are retained.