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,那其实是富文本。有人可以帮忙吗?