我收到以下错误:
Application tried to present a nil modal view controller on target <UINavigationController: 0x2007af00>.
在以下代码中:
-(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];
}
知道为什么吗?
答案 0 :(得分:2)
我想知道你为什么先解雇你的观点...从你的方法中删除这一行
[self dismissModalViewControllerAnimated:NO];
最好首先检查设备是否配置为发送电子邮件。见link
答案 1 :(得分:0)
navigationController
是所有UIViewControllers
的属性,它为您提供父导航视图控制器(如果存在)。听起来你从未将yourviewController
添加到导航控制器的视图控制器堆栈中。