I have a navigationController where I launch the ModalViewController from. In this ModalViewController, I will show the MailComposer, which itself will be another ModalViewController.
Now, if the user clicks the submit button, MailComposerView must be fired by another ModalViewController. To do this, I call the delegate method in mailComposerController.
Now only MailComposerView will be fired, but there is no other ModalViewController, and I get the 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 if I am wrong?
First ModalView
- (void)addList {
NSLog(@"addList");
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 AddListViewController calling MailView
MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init];
mailComposer.mailComposeDelegate = self;
NSString *subject = [NSString stringWithFormat:@"Group invite for groupname: %@", @"mhm"];
[mailComposer setSubject:subject];
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 delegate finsihAddList
[self dismissModalViewControllerAnimated:YES]