gpt4 book ai didi

iphone - 两个 ModalViewController

转载 作者:搜寻专家 更新时间:2023-10-30 19:53:42 25 4
gpt4 key购买 nike

我有一个 navigationController,我从那里启动 ModalViewController。在这个 ModalViewController 中,我将显示 MailComposer,它本身是另一个 ModalViewController。

现在,如果用户点击发送按钮,MailComposerView 和其他 ModalViewController 应该被关闭。为此,我在 mailComposerController 中调用了一个委托(delegate)方法。

现在只有 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 委托(delegate)中

[self dismissModalViewControllerAnimated:YES];

最佳答案

我遇到了类似的问题。我有一堆模态呈现的 View Controller 。当我试图从可见的开始消除它们并向下移动堆栈时,我会因同样的错误而失败。解决方案是关闭堆栈底部的 View Controller 。它会忽略它上面的所有内容。

在您的情况下,我的解决方案相当于更改 mailComposerController 方法,使其仅包含一行(不关闭最顶层的模态 vie Controller )。

[self.delegate finishAddList:checkmark andListName:listName.text];

我知道您已经解决了您的问题,但认为这可能对其他人有帮助。

关于iphone - 两个 ModalViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3988432/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com