Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dismissModalViewController Hides the parent view behind status bar

I have a very strange issue here. I am using a present modal view controller to display my MFMailComposer ViewController on top of a ViewController which is placed with in a Navigation Bar.

[self presentModalViewController:emailviewController animated:YES];

to hide , I use ...

-(void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{

    [self dismissModalViewControllerAnimated:YES];
}

Everything works fine but when I dismiss my MailComposer the original view controller hides behind the status bar .

I have tried to modify view offset by 10 using setFrame method but It din't worked . (this is tired before and after the modal view controller is presented and dismissed )

I have tried by hiding status bar temporarily but didn't worked.

I have tried self.navigationcontroller presentmodalviewcontrolle but that didn't worked too...

Any ideas or suggestions would be highly appreciated

After dismissmodalviewcontroller called

edited : Most of the people give me a suggestion to modify the offset manually. Well that does not work . Because if I do that in my viewDidLoad/viewWillapper of the original viewcontroller method then It shifts my view before the present modal view controller whereas after I load the modal view controller It becomes normal.

  • (void) viewDidAppear: (BOOL) animated { CGRect frame = self.navigationController.view.frame; frame.origin.y = 20; self.navigationController.view.frame = frame; }

Changing offset results in this

like image 527
Kunal Balani Avatar asked Jun 21 '12 00:06

Kunal Balani


1 Answers

Try putting this in ViewDidAppear:

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];

Worst case, if it is always happening only after the modal view controller is dismissed, declare a boolean for afterFirstLaunch in the .h and put this in viewDidAppear:

if(afterFirstLaunch){
      CGRect frame = self.navigationController.view.frame;
      frame.origin.y = 20;
      self.navigationController.view.frame = frame;
}
else {
      afterFirstLaunch = true;
 }
like image 62
WolfLink Avatar answered Sep 28 '22 05:09

WolfLink