iOS:自定义键盘:我想将图像发送到 textDocumentProxy(输入控件)

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

问题描述

我正在实现只有图像的自定义键盘,并希望在单击图像时将图像发送到 textDocumentProxy/input 控件,例如 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.

推荐答案

下面是复制图片到粘贴板

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(输入控件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)
Resume game cocos2d(恢复游戏 cocos2d)
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)
[ios.cocos2d+box2d]how to disable auto-rotation?([ios.cocos2d+box2d]如何禁用自动旋转?)
Cocos2d - apply GLImageProcessing effect to CCSprite(Cocos2d - 对 CCSprite 应用 GLImageProcessing 效果)
Storing and reading files from Documents directory iOS 5(从 Documents 目录存储和读取文件 iOS 5)