UIPboardboard filter when copying web content from safari to content UIWebView

My application is a rich editor that uses the UIWebView and HTML5 contenteditable features.

Now my application has some problems copying web content from safari to my UIWebView when web content has any image. I want to replace the html tag of the <img> image in UIPasteboard with some of my images,

However, when I use the following code to check the cardboard, there is NO any image in the cardboard box. But copying / pasting the safari image into my application is working fine.

 UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; NSLog(@"clip board strings = %@", pasteboard.strings); NSLog(@"clip board urls = %@", pasteboard.URLs); NSLog(@"clip board images = %@", pasteboard.images); 

If I copy the image and text from safari, then open my application, NSLog below:

 2012-04-20 14:53:37.558 clip board strings = ( "text" ) 2012-04-20 14:53:37.559 [46800:17903] clip board urls = ( ) 2012-04-20 14:53:37.559 [46800:17903] clip board images = (null) 

I want to ask how to get image information from UIPastboard and how to manipulate it?

Thanks in advance.

+7
source share
1 answer

You can extract the image from cardboard using:

 UIImage *image = [UIPasteboard generalPasteboard].image; 

You can check if the cardboard contains an image file using:

 BOOL imgPasteBoard= [[pasteboard pasteboardTypes] containsObject:@"public.png"]; 

then checking the bool value. You can also try using this code.

 [[UIPasteboard generalPasteboard] containsPasteboardTypes:UIPasteboardTypeListImage]; UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; if (pasteboard.image!= nil) { [self insertImage:pasteboard.image]; //insert image being a function where you write the code to insert Images to psteboard } 

Hope this helps you.

Now load UIImage using the following code: -

 NSData *imageData = UIImagePNGRepresentation(image); [webView loadData:imageData MIMEType:imageMIMEType textEncodingName:nil baseURL:nil]; 
+1
source

All Articles