【发布时间】:2013-12-10 00:03:31
【问题描述】:
我有一个 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 中完美运行。
出现黑屏时,无法返回应用程序。您必须终止应用程序,然后重新启动。
有人遇到同样的问题吗?请帮忙。谢谢。
【问题讨论】:
-
代码似乎是正确的,检查imgData是否为nil
-
imgData 不为零。并且 [messageController addAttachmentData..] 返回 YES。所以附上了图片。
标签: ios iphone ipad ios7 imessage