Iphone 关于纸板夹
我想使用UIPasteboard实现一个剪贴板应用程序,它可以将纯文本和富格式的web内容复制到pasteboard,然后显示在我的TextView或WebView上。我该怎么做 我有下面的代码,它可以得到纯文本,但是如果我复制一个web内容呢Iphone 关于纸板夹,iphone,ios,ipad,uipasteboard,Iphone,Ios,Ipad,Uipasteboard,我想使用UIPasteboard实现一个剪贴板应用程序,它可以将纯文本和富格式的web内容复制到pasteboard,然后显示在我的TextView或WebView上。我该怎么做 我有下面的代码,它可以得到纯文本,但是如果我复制一个web内容呢 if ([pasteboard containsPasteboardTypes:[NSArray arrayWithObjects:@"public.utf8-plain-text", @"public.text", nil]]){ if (![
if ([pasteboard containsPasteboardTypes:[NSArray arrayWithObjects:@"public.utf8-plain-text", @"public.text", nil]]){
if (![_contentList containsObject:pasteboard.string]){
NSLog(@"String representation present: %@", pasteboard.string);
[self addContentList:pasteboard.string];
[pasteboard setValue:@"" forPasteboardType:UIPasteboardNameGeneral];
}
}
尝试改用
UIPasteboardTypeListString
[[UIPasteboard generalPasteboard] containsPasteboardTypes:UIPasteboardTypeListString];
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
if (pasteboard.string != nil) {
[self insertText:pasteboard.string];
}
我认为这只能捕获字符串,如果复制web内容会怎么样?例如html?请参见此处的富文本答案-但不确定从网页复制时它是否有效。情况并非如此,我想要的是从UIPasteboard获取内容,而不是在其中设置内容。