Home > DeveloperSection > Forums > about UIPasteboard clip in iPad Programming
ben reitman
ben reitman

Total Post:96

Points:676
Posted on    June-04-2013 1:39 AM

 iPhone iPhone 
Ratings:


 1 Reply(s)
 1120  View(s)
Rate this:
Hi Developers,

I want to implement a clipboard app using UIPasteboard, which can copy plain text and also rich format , web content in to the pasteboard , and then display on my TextView or WebView. how can i do that?

I have following code and it can get the plain text , but what if i copy a web content?

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

Thanks in advance. 


AVADHESH PATEL

Total Post:604

Points:4228
Posted on    June-05-2013 8:30 AM

Hi Ben,

Try using UIPasteboardTypeListString instead

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

I hope it resolve your problem. 

Don't want to miss updates? Please click the below button!

Follow MindStick