13
votes

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

1
Does your original view controller have a status bar set to hidden or no? - Ladislav
nope .. I haven't touched the status bar yet - Kunal Balani
So no status bar changes in the modal view controller as well as in the original view controller? - Ladislav
No. the status bar remains at the same place it's the viewcontroller behind the modal view controller changes - Kunal Balani
Ok. My Problem is fixed but I dont know how. My Navigation Controller was initially intialized by self.navigationController setViewControllers: Array of View controller . In one of them I had disabled auto rotation by sending shouldAutorotateTo.... to return as NO whereas in others it was YES . I changed that one to comply with others and it worked. I dont have any idea whats going on but . I will simulate this and file a bug for Apple unless any one else could help me to figure out whats going on under the hood - Kunal Balani

1 Answers

3
votes

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