I've created a custom container view controller using the new UIViewController container view controller methods in iOS 5.
Trouble is, even though my container controller's child UIViewController has definesPresentationContext = YES, when it creates and presents another modal view controller, UIKit sets the container (rather than the child) as the presenting controller.
For example, in MyChildViewController.m:
- (void)showMailComposeView:(id)sender {
__block MFMailComposeViewController *vc =
[[MFMailComposeViewController alloc] init];
vc.mailComposeDelegate = self;
vc.subject = @"Subject";
self.definesPresentationContext = YES;
[self presentViewController:vc animated:YES completion:^{
if ([self.modalViewController isEqual:vc])
NSLog(@"This should print...");
if ([vc.presentingViewController isEqual:self.parentViewController])
NSLog(@"... but this shouldn't");
// NOTE: Both log statements printed
}];
}
- (void)mailComposeController:(MFMailComposeViewController*)controller
didFinishWithResult:(MFMailComposeResult)result
error:(NSError*)error
{
[self dismissViewControllerAnimated:YES completion:^{}];
// NOTE: self.parentViewController.view now displays instead of self.view
}
Where am I going wrong?
How do I ensure it's the child view which gets revealed when the modal view gets dismissed (rather than the container view)?