我有一个 navigationController 从我启动 ModalViewController 的地方。在这个 ModalViewController 中,我将显示 MailComposer,它本身是另一个 ModalViewController。
现在,如果用户点击发送按钮,MailComposerView 以及其他 ModalViewController 应该被关闭。为此,我在 mailComposerController 中调用了一个委托方法。
现在只有 MailComposerView 将被解除,但其他 ModalViewController 不会被解除,我收到以下错误消息
attempt to dismiss modal view controller whose view does not currently appear. self = <UINavigationController: 0x724d500> modalViewController = <UINavigationController: 0x72701f0>
你有什么想法我做错了吗?
第一个模态视图
- (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]; }
在调用 MailView 的 AddListViewController
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];
在 mailComposerController 方法中
[self.navigationController dismissModalViewControllerAnimated:YES];
[self.delegate finishAddList:checkmark andListName:listName.text];
在 finsihAddList 委托中
[self dismissModalViewControllerAnimated:YES];