3

ModalViewControllerを起動する場所からnavigationControllerがあります。このModalViewControllerでは、それ自体が別のModalViewControllerであるMailComposerを表示します。

これで、ユーザーが送信ボタンを押すと、他のModalViewControllerと同様にMailComposerViewを閉じる必要があります。そのために、mailComposerControllerでデリゲートメソッドを呼び出します。

これで、MailComposerViewのみが閉じられますが、他のModalViewControllerは閉じられず、次のエラーメッセージが表示されます。

attempt to dismiss modal view controller whose view does not currently appear. 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];    }

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];
4

2 に答える 2

8

私も同様の問題を抱えていました。私はモーダルに提示されたビューコントローラーのスタックを持っていました。表示されているものから始めてスタックを下に移動しようとすると、同じエラーで失敗します。解決策は、スタックの一番下にあるViewControllerを閉じることでした。それはその上のすべてを却下します。

あなたの場合、私の解決策は、mailComposerControllerメソッドを変更して、1行だけが含まれるようにすることです(最上位のモーダルビューコントローラーを却下しません)。

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

あなたはすでに問題を解決していると思いますが、これは他の人にも役立つかもしれないと思いました。

于 2011-09-01T13:23:23.437 に答える
3

最初の却下はまだ呼び出されていないため、2番目の却下を遅らせて呼び出す必要があります。

[self performSelector: @selector(finish:) withObject: obj afterDelay: 0.0f];

0.0fの遅延は意図的なものであり、次のイベントループで実行されることを意味します。

于 2010-10-21T14:27:45.953 に答える