I need to support inserting images in a UITextView . If the image is copied to the clipboard, the " Paste " option does not appear. This happens when there is text on the clipboard.
Here's how to override the Paste parameter in a custom UITextView . But I need help on how to get an opportunity to seem to start with ...
// This gets called when user presses menu "Paste" option - (void)paste:(id)sender{ UIImage *image = [UIPasteboard generalPasteboard].image; if (image) { NSTextAttachment *textAttachment = [[NSTextAttachment alloc] init]; textAttachment.image = image; NSAttributedString *imageString = [NSAttributedString attributedStringWithAttachment:textAttachment]; self.attributedText = imageString; } else { // Call the normal paste action [super paste:sender]; } }
I came across several related questions, but they didn’t help for an inexperienced developer like me: How do I get UIMenuController to work for a custom view? How to insert an image from a cardboard table into a UITextView? p>
source share