问题描述
我正在实现只有图像的自定义键盘,并希望在单击图像时将图像发送到 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(输入控件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)