views:

17

answers:

1

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];
A: 

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.

jv42
Tried it but still get the same error [self.delegate performSelector: @selector(finishAddList:) withObject:listName.text afterDelay: 0.0f];
gabac
Have you tried removing animation to the second dismiss? And have you tried with a bigger delay?
jv42
bigger deal helps! thx a lot
gabac