Copying and pasting image into a textbook in simulator

老子叫甜甜 提交于 2019-11-29 15:31:48

问题


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
}

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.


回答1:


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

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

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

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

May This help lot.

Happy Coding.



来源:https://stackoverflow.com/questions/29597700/copying-and-pasting-image-into-a-textbook-in-simulator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!