about UIPasteboard clip in iPad Programming

Total Post:96


 1876  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. 
  1. 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. 

      Modified On Mar-30-2018 01:37:32 AM


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.