2
我試圖使用UIPasteboard
從UIWebView
中獲取複製圖像。使用UIPasteboard從UIWebView中獲取圖像
[_myWebView copy:[UIApplication sharedApplication]]; //Copy selection to general pasteboard
NSArray* types = [NSArray arrayWithArray:[UIPasteboard generalPasteboard].pasteboardTypes];
NSLog(@"Type %@", [types objectAtIndex:0]);
if([[UIPasteboard generalPasteboard] containsPasteboardTypes:UIPasteboardTypeListString]){
NSLog(@"text selected %@",[UIPasteboard generalPasteboard].string);
}else if([[UIPasteboard generalPasteboard] containsPasteboardTypes:UIPasteboardTypeListImage]){
NSLog(@"image selected");
}else if ([[UIPasteboard generalPasteboard] containsPasteboardTypes:UIPasteboardTypeListURL]){
NSLog(@"url selected");
}
如果我複製文本這是確定的,但如果我複製一個像我得到:
WebController.m:445 > Type com.apple.rtfd
WebController.m:458 > text selected {\rtf1\ansi\ansicpg1252
{\fonttbl\f0\fnil\fcharset0 .SFUIText-Regular;}
{\colortbl;\red255\green255\blue255;\red45\green45\blue45;}
\deftab720
\pard\pardeftab720\qc\partightenfactor0
\f0\fs32 \cf2 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 \
}
我試圖從不同的網站有許多圖像,但我總是得到類型RTFD,那其實是富文本。有人可以幫忙嗎?