मुझे UITextView
में छवियों के पेस्टिंग का समर्थन करने की आवश्यकता है। क्लिपबोर्ड पर कॉपी की गई छवि के साथ, "Paste
" विकल्प पॉप अप प्रतीत नहीं होता है। यह तब होता है जब क्लिपबोर्ड पर टेक्स्ट होता है।चिपकाए गए चित्र प्राप्त करने के लिए UITextView को कैसे सक्षम करें
यह कस्टम UITextView
में paste
विकल्प को ओवरराइड करने का तरीका है। लेकिन मैं कैसे विकल्प के साथ शुरू करने के लिए दिखाने के लिए पाने के लिए पर मदद की जरूरत है ...
// 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];
}
}
मैं कुछ संबंधित प्रश्नों में आए, पर वे अपने आप की तरह एक अनुभवहीन डेवलपर के लिए मददगार नहीं थे: How to get UIMenuController work for a custom view?, How to paste image from pasteboard on UITextView?
आपका कोड सही है, लेकिन एक छवि कॉपी करने के बाद मेरा पेस्ट विकल्प नहीं आ रहा है। इसे कैसे हल करें? –
क्या आपको UITextView को इस कोड के साथ बनाए गए कस्टम क्लास का उदाहरण होने के लिए सेट करना याद आया? –
@MattKoala धन्यवाद आपका उत्तर सही है। – Urmi