问题
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