Copy HTML to UIPboardboard

I want to transfer HTML from my application to the iPhone email application. I already have HTML text - not to say <span style = 'color: red'> Test </span> I can post this on the UIPasteBoard, but when I paste it into the mail, I get the html source.

When I put the same line in the HTMLView - select it there and copy it, it will be inserted into the red text by mail.

What do I need to do to put the string in the UIPasteBoard so that it is inserted in red text in the mail application? I searched for “types of formats” - and found that the UIPasteBoard returns “cardboard type Aplle Web Archive” when I have an item (copied from UIWebView) to the clipboard. But setting this type when adding content to the UIPasteBoard does not insert anything into the mail application.

Manfred

+3
html ios iphone uipasteboard
source share
4 answers

No, he can not. UIPasterBoard only accepts strings, images, URLs and colors.

-12
source share

This is not true. you can insert ANYTHING into the cardboard, go read the documents.

Finally, I put together a tutorial that shows how to copy HTML into a Mail application. http://mcmurrym.wordpress.com/2010/08/13/pasting-simplehtml-into-the-mail-app-ios/

+8
source share

on the same link that you indicated in your comment, you will find this paragraph at the top.

A uniform type identifier (UTI) is often used for a presentation type (sometimes called a cardboard type). For example, you can use kUTTypeJPEG (constant for public.jpeg) as the view type for JPEG data. However, applications are free to use any string that is required for the view type ; however, for application-specific data types, it is recommended that you use a reverse DNS record to ensure type uniqueness (for example, com.myCompany.myApp.myType).

Right below is a link to here. http://developer.apple.com/iphone/library/documentation/FileManagement/Conceptual/understanding_utis/understand_utis_intro/understand_utis_intro.html#//apple_ref/doc/uid/TP40001319

What explains the UTIs.

Finally, this link gives you MULTIPLE types of http://developer.apple.com/iphone/library/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html#//apple_ref/doc/uid/TP40009259-SW1

Of course, this list is NOT ALL, as you can create your own types.

I have successfully inserted html into the mail application. I will give you a good place to start ...

Create an application that displays data types in cardboard. Open the safari on the device, copy the web page. Launch the app. You will see that the paperboard type is "Apple Web Archive Cardboard Type". Please note that this is really a cardboard type (custom). If you try to duplicate a samurai mobile copy and paste the function yourself by creating a web archive and trying to paste it as text in the mail application, it will show the web archive file as raw xml. If you define the type as "Apple Web Archive Cardboard Type", the mail application will actually format the insert as html.

If you want to know what the web archive looks like. On the Safari desktop, just save the web page as an archive and look at the file in a text editor (text editing will try to parse it so you can use another program to view the xml archive).

Please read all the documentation as you may find that you can create custom types in the link you sent me.

+2
source share

I have an HTML copy running, so it is inserted correctly in the Mail and Notes embedded applications. It looks like this:

NSString *htmlContent = @"This is <span style='font-weight:bold'>HTML</span>"; NSString *content = @"This is HTML!"; NSDictionary *dict = @{(NSString *)kUTTypeText: content, (NSString *)kUTTypeHTML: htmlContent}; [[UIPasteboard generalPasteboard] setItems:@[dict]]; 

To access these type constants, you need to import this:

 #import <MobileCoreServices/UTCoreTypes.h> 
+1
source share

All Articles