views:

178

answers:

1

hi,
i have copied image from UIwebView using clipboard and i want to mail it.For this,I use general pasteboard to get data,but there is a problem in retrieving data.When i check the pasteboard current data,it says the it has Apple Web Archive pasteboard type data,how to read this.here is my code of retriving text.

UIPasteboard* pasteboard = [UIPasteboard generalPasteboard];
NSArray* array = [pasteboard pasteboardTypes];
for (NSString* type in array) {
    NSLog(@"%@",type);
}
NSString* item = @"Apple Web Archive pasteboard type";
NSData* val = [pasteboard dataForPasteboardType:item];

I tried to create a UIImage using this data but that didn't work.

A: 

I don't understand what you mean by mail it? You can paste the webpage image copy right into the mail app and it will appear as an image.

You can rebuild the data from the Apple Web Archive pasteboard type if you need to manual. It is essentially a XML document with html and the actual image data all within. The html and accompanying images are base64 encoded. If you want to look at an archive example save this, or perhaps a simple webpage in safari as an archive. Open the archive file in something like Text wrangler. Text edit will probably try to render it.

I've written a post on how to make an Apple Web Archive pasteboard type that might help you understand the process.

http://mcmurrym.wordpress.com/2010/08/13/pasting-simplehtml-into-the-mail-app-ios/

I take it you are trying to mail it from within your app and not using the mail app?

If this is the case you will probably have to get the xml from the pasteboard, find the tag that holds the encoded image data, decode it and create an image from the decoded data.

maxpower
forgot to update the status of question.I figured out the solution after i posted the question.thanks though for your time.
Farhan