ABOUT UIPASTEBOARD CLIP IN IPAD PROGRAMMING

ben reitman

Total Post:96

Points:676
Posted by  ben reitman
iPhone 
 1404  View(s)
Ratings:
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. 
  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: about UIPasteboard clip in iPad Programming

    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. 

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!