-1

我有一个 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>  --");

}

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

4

1 回答 1

0

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

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

在尝试将其呈现为模态视图控制器之前检查您的picker变量是否为非零也是一个好主意。

于 2012-07-02T17:57:38.040 回答