Reputation: 33644
I am getting the following error:
Application tried to present a nil modal view controller on target <UINavigationController: 0x2007af00>.
On the following code:
-(void) showAddressBookDialog
{
[self presentMailComposeViewController:nil];
}
- (void)presentMailComposeViewController:(NSString *)recipient {
// Create the compose email view controller
MFMailComposeViewController *composeEmailViewController = [[MFMailComposeViewController alloc] init];
[composeEmailViewController setMailComposeDelegate:self];
[composeEmailViewController setSubject:@"Join me on X"];
[composeEmailViewController setToRecipients:[NSArray arrayWithObjects:recipient, nil]];
[composeEmailViewController setMessageBody:@"" isHTML:YES];
[composeEmailViewController setModalPresentationStyle:UIModalPresentationFormSheet];
[self dismissModalViewControllerAnimated:NO];
self.inviteFriendsMailComposerVC_ = composeEmailViewController;
//[self.navigationController presentModalViewController:composeEmailViewController animated:YES];
[self.navigationController presentViewController:composeEmailViewController animated:YES completion:nil];
[composeEmailViewController release];
}
Any idea why?
Upvotes: 1
Views: 6720
Reputation: 2807
I wonder why you are dismissing you view first... remove this line from your method
[self dismissModalViewControllerAnimated:NO];
Its better to check first whether the device is configured to send email. See this link
Upvotes: 2
Reputation: 38239
navigationController
is a property of all UIViewControllers
which gives you their parent navigation view controller, if one exists. It sounds like you never added yourviewController
to a navigation controller's stack of view controllers.
Upvotes: 0