为什么尝试在此处显示MFMailComposeViewController会锁定屏幕



>我有一个iPad应用程序,由一个根视图控制器组成,该控制器加载第二个视图控制器。在第二个视图控制器中,我有一个按钮应该显示一个MFMailComposeViewController

我的问题是:
在模拟器上,这工作正常。但是,在实际设备上按此按钮会锁定屏幕,并且似乎禁用了所有用户与界面的交互

我的代码是:

//************** Send Email using Default IM ************************
-(void) showEmailModalView
{
    NSLog(@"Start method <ExportStatisticsController> : <showEmailModalView>  --");

    //    emailTextField.text = [emailTextField.text stringByReplacingOccurrencesOfString:@"(null)" withString:@""];
    //    subjectTextField.text = [subjectTextField.text stringByReplacingOccurrencesOfString:@"(null)" withString:@""];
    //    messageBodyTextView.text = [messageBodyTextView.text stringByReplacingOccurrencesOfString:@"(null)" withString:@""];
    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self; // &lt;- very important step if you want feedbacks on what the 
    //user did with your email sheet
    [picker setSubject:@""];
    NSArray *torec=[[NSArray alloc] initWithObjects:@"xyz@company.com", nil];
    [picker setToRecipients:torec];
    [torec release];
//------ message body ---
    NSString *body =@"";
    [picker setMessageBody:body isHTML:NO]; // depends. Mostly YES, unless you want to send it as plain text (boring)
    picker.navigationBar.barStyle = UIBarStyleBlack; // choose your style, unfortunately, Translucent colors behave quirky.
//    picker.ModalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:picker animated:YES];
    [picker release];
    NSLog(@"End method <ExportStatisticsController> : <showEmailModalView>  --");
}

我可能做错了什么导致这样的屏幕冻结?

设备可能未设置为发送邮件。

在使用MFMailComposeViewController之前,应致电[MFMailComposeViewController canSendMail]以确保设备配置为发送邮件。

在尝试将picker变量呈现为模态视图控制器之前,检查它是否为非 nil 可能也是一个好主意。

相关内容

  • 没有找到相关文章

最新更新