I have a navigationController from where I launch a ModalViewController. In this ModalViewController I will display the MailComposer which itself another ModalViewController.
Now if the user hits the send button the MailComposerView should be dismissed as well the other ModalViewController. For that I call a delegate method in the mailComposerController.
Now only the MailComposerView will be dismissed but no the the other ModalViewController and I get following error message
attempt to dismiss modal view controller whose view does not currently appear. self = <UINavigationController: 0x724d500> modalViewController = <UINavigationController: 0x72701f0>
Do you have any Idea would I'm doing wrong?
First ModalView
- (void)addList {
NSLog(@"addList");
//AddListViewController *addListViewController = [[AddListViewController alloc] init];
AddListViewController *addListViewController = [[AddListViewController alloc] initWithStyle:UITableViewStyleGrouped];
addListViewController.delegate = self;
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addListViewController];
navigationController.navigationBar.barStyle = UIBarStyleBlack;
navigationController.navigationBar.translucent = YES;
[self presentModalViewController:navigationController animated:YES];
[navigationController release];
[addListViewController release]; }
In the AddListViewController calling the MailView
MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init];
mailComposer.mailComposeDelegate = self;
NSString *subject = [NSString stringWithFormat:@"Group invite for groupname: %@", @"mhm"];
[mailComposer setSubject:subject];
// Fill out the email body text
NSString *emailBody = @"This is an group invite bla bla";
[mailComposer setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:mailComposer animated:YES];
[mailComposer release];
In the mailComposerController method
[self.navigationController dismissModalViewControllerAnimated:YES];
[self.delegate finishAddList:checkmark andListName:listName.text];
In the finsihAddList delegate
[self dismissModalViewControllerAnimated:YES];