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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

No resource found that matches the given name: attr #39;android:keyboardNavigationCluster#39;. when updating to Support Library 26.0.0(找不到与给定名称匹配的资源:attr android:keyboardNavigationCluster.更新到支持库 26.0.0 时) - IT屋-程序员软
How to resize UITextView on iOS when a keyboard appears?(出现键盘时如何在iOS上调整UITextView的大小?)
How to reliably detect if an external keyboard is connected on iOS 9?(如何可靠地检测 iOS 9 上是否连接了外部键盘?)
How to mimic Keyboard animation on iOS 7 to add quot;Donequot; button to numeric keyboard?(如何在 iOS 7 上模拟键盘动画以添加“完成数字键盘的按钮?)
How do I dismiss the iOS keyboard?(如何关闭 iOS 键盘?)
Is possible to simulate touch event using an external keyboard on ios jailbroken?(是否可以在 ios 越狱后使用外部键盘模拟触摸事件?)