This is somewhat of a guess, but an educated guess after having played around with your code a bit.
When you present a modal view it is added as a subview of the view belonging to the controller on which presentModalViewController
was called. Since the modal view is intended to be displayed full screen it would appear as though internally the frame of the superview is being made full screen.
I put the following in your MyDetailViewController:
- (void)viewDidLoad {
[super viewDidLoad];
CGRect frame = self.navigationController.view.frame;
NSLog(@"%@", NSStringFromCGRect(frame));
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
CGRect frame = self.navigationController.view.frame;
NSLog(@"%@", NSStringFromCGRect(frame));
}
Which resulted in the following output:
2010-09-19 00:23:51.823 ModalTest[2478:207] {{0, 164}, {320, 316}}
2010-09-19 00:23:56.178 ModalTest[2478:207] {{0, 0}, {320, 480}}
The first line was output when the detail first appeared. The second line was output when the modal view was dismissed.
Now I actually don't particularly like the solution I found, but this has the desired affect. In your sendMail
method:
ModalTestAppDelegate* appDelegate = [[UIApplication sharedApplication] delegate];
[appDelegate.viewController presentModalViewController:controller animated:YES];
And in your mailComposeController:didFinishWithResulterror:
method:
ModalTestAppDelegate* appDelegate = [[UIApplication sharedApplication] delegate];
[appDelegate.viewController dismissModalViewControllerAnimated:YES];
Basically this has the effect of making sure it's the full screen view holding the main UI of your application that presents the full screen modal view. I don't think it's ideal however because I'm not a huge fan of deep parts of the code reaching up into the app delegate like that.