Reputation: 1015
How can we set an image behalf of the text?
Following code is to display text in the input view:
[self.textDocumentProxy insertText:[key currentTitle]];
My code of paste board to display the image :
NSData *imgData = UIImagePNGRepresentation(image);
[pasteBoard setData:imgData forPasteboardType:[UIPasteboardTypeListImage objectAtIndex:0]];
NSString* newStr = [[NSString alloc] initWithData:imgData encoding:NSUTF8StringEncoding];
[self.textDocumentProxy insertText:[pasteBoard string]];
I have created a pasteboard with the images just I have to display the images in to input view.
See this picture for the concept :
I have to select image from keyboard and show in inputview not to copy paste from library.
If anyone know please reply as answer or any suggestion will also acceptable.
Thanks!
Upvotes: 5
Views: 2538
Reputation: 1015
I have get solution for this question use clipboard copy and paste
Code :
UIPasteboard *pasteBoard = [UIPasteboard generalPasteboard];
NSData *data = [self.Videoassets objectAtIndex:btn.tag];
NSLog(@"File size is : %.2f MB",(float)data.length/1024.0f/1024.0f);
[pasteBoard setData:data forPasteboardType:@"public.mpeg-4"];
Upvotes: 2
Reputation: 973
I don't think it's possible to add directly an image from a custom keyboard. A workaround would be to copy the image to the pastboard and paste it in the destination area. (It's not very nice but It's the only way I see actually)
Upvotes: 2