我在iPhone和iPad上使用以下代码iPad兼容。
if([MFMailComposeViewController canSendMail])
{
dispatch_async(dispatch_get_main_queue(), ^{
MFMailComposeViewController *mailcomposer=[[MFMailComposeViewController alloc] init];
[mailcomposer setMailComposeDelegate:self];
[mailcomposer setToRecipients:[NSArray arrayWithObject:recipients]];
[self presentViewController:mailcomposer animated:YES completion:nil];
});
}
它在iPhone上运行良好,但在iPad的情况下,模态已打开,几秒钟后它就会自动被解雇。将其置于调试模式后,我在下面找到了日志。
viewServiceDidTerminateWithError: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "The operation couldn’t be completed. (_UIViewServiceInterfaceErrorDomain error 3.)" UserInfo=0x7fbb904040f0 {Message=Service Connection Interrupted}
<MFMailComposeRemoteViewController: 0x7fbb928b3250> timed out waiting for fence barrier from com.apple.MailCompositionService
答案 0 :(得分:1)
您可以在真实的物理设备/ iPad上运行MFMailComposeViewController
,但它可能会在模拟器上出现问题。