iOS:自定义键盘:我想将图像发送到textDocumentProxy(输入控件) [英] iOS: Custom keyboard: I want to send images to the textDocumentProxy(Input controls)

查看:342
本文介绍了iOS:自定义键盘:我想将图像发送到textDocumentProxy(输入控件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在实现只包含图像的自定义键盘,并希望将图像发送到textDocumentProxy /输入控件,如textview,点击图片但不能克服它。
到目前为止我能够将文本/字符串发送到输入控件而不是图像。

I am implementing custom keyboard with only images and wanted to send images to textDocumentProxy/input controls like textview on click of image but not get over it. so far I am able to send text/string to input controls but not images.

是否可以将图像发送到输入控件?

Is it possible to send images to input controls?

我们非常感谢任何建议或解决方案。

Any suggestion or solution is highly appreciated.

推荐答案

以下是复制图像的代码粘贴板

Following is the code for the copy image into pasteboard

NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://warp.povusers.org/images/test.png"]];
UIPasteboard *pasteBoard=[UIPasteboard generalPasteboard];
[pasteBoard setData:data forPasteboardType:@"public.png"];

现在想的是在该布局中创建自定义键盘的扩展,你可以放置你的UIButton和那个按钮png图像上面的动作工具。

Now the think is that create extension of custom keyboard in that layout you can put your UIButton and that button action implement above for png image.

对于本地图像,以下代码对你来说是完整的帮助,它在我的情况下正常工作。

For Local Image following code is help full to you and it's working in my case.

UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
NSData *imgData = UIImagePNGRepresentation(@"Your UIImage Here");
[pasteboard setData:imgData forPasteboardType:[UIPasteboardTypeListImage objectAtIndex:0]];

更多您在此处访问的统一类型标识符并更改粘贴板类型。

More Uniform Type Identifiers you visit here and change Pasteboard Type.

这可以帮助您解决问题。

May this help lot and solve your problem.

已修改

允许完全访问来自设置 - >键盘 - >键盘 - >选择您的应用键盘 - >开启允许完全访问

"Allow Full Access" From Settings -> Keyboard -> Keyboards -> select your app keyboard -> On switch of "Allow Full Access"

这篇关于iOS:自定义键盘:我想将图像发送到textDocumentProxy(输入控件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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