Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When Dismissing a Modal View Controller the underlying UIScrollView resizes to fullscreen

I have a layout with a custom status bar on top [below Apple's status bar], then a UIScrollview that paginates left to right in the middle section, and then I have a UIView with some custom buttons on the bottom. So a simple three-paned layout, and it works great. However, the three custom buttons on the lower view bring up a ModalViewController, and when that is dismissed, it resizes the middle UIScrollView to full-screen, and brings it to the front, covering the other two views that I have.

There are several others who have noted this behavior, but it seems that the only answers they are given is to re-resize the UIScrollView back to the original coordinates. This will work, of course, but it seems like a hack to me, and I would like ot know what is really going on behind the scenes here, and how to rectify the issue correctly.

Other SO links with the same apparent issue:

  • Dismiss modal view changes underlying UIScrollView
  • Dismissing Modal View Controller causing layout problems
  • Weird Behavior on dismissing Modal View Controller

Still others have noted that the behavior only affects 3.0 and up, so I am not sure if this is a "feature," and I am just not understanding what the behavior is supposed to be doing, or what. If anyone can shed some light on this, I would be grateful.

like image 485
ryebread Avatar asked Feb 16 '12 08:02

ryebread


1 Answers

I have exactly the same problem. In the parent of the modal view, I'm using this:

-(void)viewWillAppear:(BOOL)animated{
    [self.view setFrame:CGRectMake(0, 0, originalWidth, originalHeight)];
}

where originalWidth & originalHeight are the original sizes of my parent view.

it works fine, even if it sounds like a hack to me too.

like image 55
gluon Avatar answered Nov 05 '22 03:11

gluon