问题
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