IPhone - After dismissing Modal View Controller - gap is left at top of page IPhone - After dismissing Modal View Controller - gap is left at top of page objective-c objective-c

IPhone - After dismissing Modal View Controller - gap is left at top of page


I had the same problem. My solution was to temporarily close the status bar just before switching views:

- (void) temporarilyHideStatusBar {  [[UIApplication sharedApplication] setStatusBarHidden:YES];  [self performSelector:@selector(showStatusBar) withObject:nil afterDelay:0];}- (void) showStatusBar {  [[UIApplication sharedApplication] setStatusBarHidden:NO];}// Use these by calling the hide function just before a broken view switch:[self temporarilyHideStatusBar];[self doViewSwitch];// No need to call [self showStatusBar]; explicitly.

I experimented with other code-based solutions, and I like this one the best because it works 100% of the time - some of my frame-based solutions only worked most of the time - and because it has minimal user-visible effects.

I suspect this is an Apple bug, and it would be nice to hear the official word from them on the best workaround.


Turns out this was happening because I was calling my modalviewcontroller on the current view controller, but my view controller already had a another view controller loaded as a subview. Once I changed it to make the view controller in the subview, load the modal, then it went away. Thanks for all your help.


I ran into the same issue. Not sure what causes it, but I fixed it with the following line of code just after I dismiss my modal view:

[self.view setFrame:CGRectMake(0, 10, self.view.frame.size.width, self.view.frame.size.height)];

Just adjust the Y offset to meet your needs. In another instance I had to make it 20 instead of 10.