我有一个 MFMessageComposeController,我想通过 iMessage 发送图像(我的 iPad 上没有 SMS)。
这是我的代码:
- (void)presentMessageController {
if(![MFMessageComposeViewController canSendAttachments])
{
UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"Your device doesn't support sharing photos via SMS!"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[warningAlert show];
return;
}
MFMessageComposeViewController *messageController = [[MFMessageComposeViewController alloc] init];
messageController.messageComposeDelegate = self;
[messageController addAttachmentData:imgData typeIdentifier:(NSString *)kUTTypePNG filename:@"image.png"];
// Present message view controller on screen
[self presentViewController:messageController animated:YES completion:nil];
}
问题似乎出在[messageController addAttachmentData...]中。messageController 没有出现,而是出现了一个空白屏幕,并且应用程序挂起,1-2 秒后,代理以 MessageComposeResultCancelled 响应,我在控制台中看到了这个:
等待来自 com.apple.mobilesms.compose 的栅栏屏障超时
警告:在演示或关闭过程中尝试从视图控制器中关闭!
如果我评论该行,则会显示 messageController(打开 iMessage)。
重要的:
在 iPad 上进行测试时会发生这种情况(我仅在 iPad 2 上进行了测试,安装了 iOS 7.0.3)。相同的代码在带有 iOS 7.0.3 的 iPhone 5、4、4S 中完美运行。
当出现黑屏时,无法返回应用程序。您必须终止应用程序,然后重新启动。
有人遇到同样的问题吗?请帮忙。谢谢。