问题描述
我有一个navigationController从我启动ModalViewController的地方。在这个ModalViewController中,我将显示另一个ModalViewController的MailComposer。
现在如果用户点击发送按钮,MailComposerView应该被解除,另外ModalViewController 。为此,我在mailComposerController中调用了一个委托方法。
现在只有MailComposerView将被关闭,但没有其他的ModalViewController和我收到以下错误消息
尝试关闭视图当前未显示的模态视图控制器。 self =< UINavigationController:0x724d500> modalViewController =< UINavigationController:0x72701f0>
你有什么想法我会做错吗?
第一个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];
在AddListViewController中调用MailView
MFMailComposeViewController * mailComposer = [[MFMailComposeViewController alloc] init];
mailComposer.mailComposeDelegate = self;
NSString * subject = [NSString stringWithFormat:@groupname for groupname:%@,@mhm];
[mailComposer setSubject:subject];
//填写电子邮件正文文本
NSString * emailBody = @这是一个组邀请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];
在finihAddList委托中
[self dismissModalViewControllerAnimated:YES];
您必须稍后再次打电话,因为调用时,第一个关闭还没有完成。
[self performSelector:@selector(finish :) withObject:obj afterDelay :0.0f];
0.0f的延迟是有意的,这意味着它将在下一个事件循环中完成。 / p>
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];
You must call the second dismiss with a delay, because the first dismiss hasn't been done yet when called.
[self performSelector: @selector(finish:) withObject: obj afterDelay: 0.0f];
A delay of 0.0f is intentional, it means it will be done in the next event loop.
这篇关于两个ModalViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!