0

UIPasteboard を使用してクリップボード アプリを実装したいと考えています。これは、プレーン テキストとリッチ フォーマット、Web コンテンツをペーストボードにコピーし、TextView または WebView に表示できます。どうやってやるの?

次のコードがあり、プレーンテキストを取得できますが、Web コンテンツをコピーするとどうなりますか?

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];
    }

}
4

1 に答える 1

0

UIPasteboardTypeListString代わりに使用してみてください

[[UIPasteboard generalPasteboard] containsPasteboardTypes:UIPasteboardTypeListString];
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; 
if (pasteboard.string != nil) {
    [self insertText:pasteboard.string]; 
}

http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIPasteboard_Class/Reference.html

于 2013-06-03T14:05:24.477 に答える