MFMessageComposeViewController不显示相机图标 [英] MFMessageComposeViewController not displaying camera icon

查看:138
本文介绍了MFMessageComposeViewController不显示相机图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我手动调出新消息时,我会在文本编辑区域的左侧看到一个摄像头图标。当我使用MFMessageComposeViewController时,它不会显示此图标,这意味着您无法插入图像。我知道这可以做到,因为那些制作 txtAgif 的人可以做到这一点。一个微妙的区别是盖子已打开。这可能是他们如何使其工作的线索。

When I bring up a "New Message" manually I will see a camera icon to the left of the text edit area. When I use the MFMessageComposeViewController it will not display this icon which means you cannot insert images. I know this can be done because the guys that made txtAgif can do it. One subtle difference is the Caps is turned on. This might be a clue as to how they are getting this to work.

我知道MFMessageComposeViewController不允许您以编程方式插入图像,这就是我正在做的事情复制到UIPasteboard技巧。这部分完美无缺。

I know that MFMessageComposeViewController does not allow you to insert images programmatically and that is why I'm doing the copy to UIPasteboard trick. This part works perfectly.

同样的问题已被提出 here 这里问题没有得到解答,除了它无法完成。

This same question has been asked here and here the question has not been answered except for the "It can't be done."

这是我的第一个发布所以我没有足够高的排名来贡献其他问题的帖子。

This is my first post so I did not have a high enough ranking to contribute to the other question posts.

他们是如何做到这一点的? MFMessageComposeViewController是否有技巧或是否使用完全不同的东西?

How are they doing this? Is there a trick to MFMessageComposeViewController or are they using something completely different?

推荐答案

我已通过以下代码解决了这个问题:

I have fixed this by following code:

 UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
           pasteboard.persistent = YES;
           NSString *imagefile =app.strimagepath;

           ///  
           BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:imagefile];

           if (fileExists)
           {    
               NSData *data = UIImagePNGRepresentation([UIImage imageWithContentsOfFile:imagefile]);
               pasteboard.image = [UIImage imageWithData:data];
           }
           NSString *phoneToCall = @"sms: 123-456-7890";
           NSString *phoneToCallEncoded = [phoneToCall stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
           NSURL *url = [[NSURL alloc] initWithString:phoneToCallEncoded];

           [[UIApplication sharedApplication] openURL:url];

此处app.strimgPath是存储在文档目录中的图像路径。当MessageView打开时。 Longpress并单击粘贴并将粘贴消息。

Here app.strimgPath is the path of image stored in document directory. when the MessageView is opened. Longpress and click on Paste and message will be pasted.

这篇关于MFMessageComposeViewController不显示相机图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆