dismissModalViewController Hides the parent view behind status bar

别来无恙 提交于 2019-12-20 18:14:12

问题


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

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; }


回答1:


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;
 }


来源:https://stackoverflow.com/questions/11130176/dismissmodalviewcontroller-hides-the-parent-view-behind-status-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!