在模拟器中将图像复制并粘贴到教科书中 [英] Copying and pasting image into a textbook in simulator

查看:140
本文介绍了在模拟器中将图像复制并粘贴到教科书中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在粘贴板中手动设置复制的内容

I'm manually setting the copied content in the pasteboard

@IBAction func onOkPressed( button: UIButton ) {
    var testImage = getImageWithColor(UIColor.redColor(), size: CGSize(width: 100, height: 100));
    UIPasteboard.generalPasteboard().image = testImage
}

func getImageWithColor(color: UIColor, size: CGSize) -> UIImage {
    UIGraphicsBeginImageContextWithOptions(size, false, 0)
    color.setFill()
    UIRectFill(CGRectMake(0, 0, 100, 100))
    var image = UIGraphicsGetImageFromCurrentImageContext()
    UIGraphicsEndImageContext()
    return image
}

但是当我将图像粘贴到模拟器中的文本框中,它不会粘贴图像。我已尝试使用本地png图像,而不是手动创建图像。当我在自定义键盘应用程序中粘贴到教科书上时,它会粘贴我的mac剪贴板中的文本而不是图像。但是,如果我以编程方式执行 UIPasteboard.generalPasteboard()。string =TeST,则会粘贴expect字符串。谁知道什么可能是错的?谢谢。

But when I paste the image into a textbox in simulator it doest not paste the image. I've tried this with a local png image as well instead of manually creating the image. When I paste onto the textbook in my custom keyboard app, it pastes the text from my mac clipboard instead of the image. However, if I programmatically do UIPasteboard.generalPasteboard().string = "TeST", the expect string gets pasted. Anyone know what could be wrong? Thanks.

推荐答案

以下是给予允许完全访问的教程启用按钮进入设置。

Following is the tutorial for give Allow Full Access enable button in to settings.

步骤1:在现有项目中创建扩展。进入XCode - >新建 - >目标 - >左侧部分应用程序扩展 - >选择自定义键盘

Step 1 : Created extension into existed project.Into XCode -> New -> Target -> Left section Application Extension -> Select Custom Keyboard

步骤2:给出扩展名新目标名称。

Step 2 : Give name of the extension new target name.

步骤3:给予允许完全访问扩展名的info.plist文件并更改 RequestsOpenAccess 的值。

Step 3 : For give Allow Full Access into extension's info.plist file and change the value of RequestsOpenAccess.

愿这个帮助很多。

快乐编码。

这篇关于在模拟器中将图像复制并粘贴到教科书中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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