我有一个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; // <- 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> --");
}
我可能做错了导致这样的屏幕冻结?
答案 0 :(得分:0)
设备可能未设置为发送邮件。
在使用MFMailComposeViewController
之前,您应该致电[MFMailComposeViewController canSendMail]
以确保设备配置为发送邮件。
在尝试将其作为模态视图控制器呈现之前,检查您的picker
变量是否为零也是一个好主意。