简体   繁体   English

iPad iOS7黑屏上的MFMessageComposeViewController addAttachmentData

[英]MFMessageComposeViewController addAttachmentData on iPad iOS7 black screen

I have a MFMessageComposeController, and I want to send images via iMessage (SMS not available on my iPad). 我有一个MFMessageComposeController,我想通过iMe​​ssage发送图像(SMS在我的iPad上不可用)。

This is my code: 这是我的代码:

- (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];
}

The problem seems to be in [messageController addAttachmentData...] . 问题似乎出在[messageController addAttachmentData ...]中 The messageController is not presented, instead a blank screen appears, and app is hanging up, and after 1-2seconds, the delegate responds with MessageComposeResultCancelled, and I see this in console: 未显示messageController,而是出现空白屏幕,并且应用程序挂起,并且在1-2秒后,委托以MessageComposeResultCancelled进行响应,我在控制台中看到了这一点:

timed out waiting for fence barrier from com.apple.mobilesms.compose 等待来自com.apple.mobilesms.compose的栅栏屏障超时

Warning: Attempt to dismiss from view controller while a presentation or dismiss is in progress! 警告:在演示或关闭过程中,请尝试从视图控制器中关闭!

If I comment that line, the messageController is presented (iMessage is opened). 如果我注释该行,则会显示messageController(已打开iMessage)。

IMPORTANT: 重要:

  1. This is happening when testing on iPad (I tested on iPad 2 only, with iOS 7.0.3 installed). 在iPad上进行测试时会发生这种情况(我仅在安装了iOS 7.0.3的iPad 2上进行过测试)。 Same code works perfect in iPhone 5, 4, 4S with iOS 7.0.3. 相同的代码可以在带有iOS 7.0.3的iPhone 5、4、4S上完美运行。

  2. When black screen appears, there is no way to return to app. 当黑屏出现时,无法返回到应用程序。 You have to terminate the app, and restart. 您必须终止该应用程序,然后重新启动。

Anybody experiencing same issue? 有人遇到同样的问题吗? Please help. 请帮忙。 Thanks. 谢谢。

try changing: 尝试更改:

[messageController addAttachmentData:imgData typeIdentifier:(NSString *)kUTTypePNG filename:@"image.png"];

to: 至:

[messageController addAttachmentData:imgData typeIdentifier:@"public.data" fileName:@"image.png"];

Call presentMessageController method after some delay 延迟一段时间后调用presentMessageController方法

[self performSelector:@selector(presentMessageController) withObject:nil afterDelay:0.5]; [self performSelector:@selector(presentMessageController)withObject:nil afterDelay:0.5];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM