Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Incorrect frame when dismissing modally presented view controller

Tags:

I am presenting a UIViewController using a custom transition and a custom UIPresentationController. The view controller's view does not cover the entire screen, so the presenting view controller is still visible.

Next, I present an instance of UIImagePickerController on top of this view controller. The problem is that when I dismiss the image picker, the presenting view controller's frame covers the entire screen instead of just the portion I want it to cover. The frame specified by frameOfPresentedViewInContainerView in my custom UIPresentationController seems to be completely ignored.

Only if present the image picker with a modalPresentationStyle of UIModalPresentationOverCurrentContext my frames remain intact (which makes sense since no views are removed from the view hierarchy in the first place). Unfortunately that's not what I want. I want the image picker to be presented full screen, which - for whatever reason - seems to mess up my layout. Anything that I might be doing wrong or forgetting here? Any suggestions?

like image 358
caryot Avatar asked Jun 21 '16 16:06

caryot


1 Answers

I tried both wrapper approaches mentioned. One side effect of using this wrapping approach is that device rotation doesn't display well - introducing black boxes around the presented view.

Instead of doing the wrapping trick, try setting the modalPresentationStyle of the presented UIImagePickerController to UIModalPresentationOverFullScreen. This means the views underneath the image picker won't be removed/restored from the view hierarchy during presentation/dismissal.

like image 67
Thomas Verbeek Avatar answered Oct 21 '22 15:10

Thomas Verbeek