cocoa touch - iOS: How to copy HTML into the cut-paste buffer? -


i'm interested in letting users copy text they've entered cut-and-paste buffer, i'd html.

is such thing possible? or need use mime format? (i have no idea.)

thanks.

the following code html out of app , apple's mail app. documentation doesn't give great deal of on this, in part it's matter of looking @ apple's apps park on pasteboard , reverse engineering that. solution draws on earlier stackoverflow post - follow links there more background.

nslog(@"place html on pasteboard");  uipasteboard* pasteboard = [uipasteboard generalpasteboard]; nsstring *htmltype = @"apple web archive pasteboard type";  // example html string nsstring* htmlstring = @"<p style=\"color:gray\"> <a href=@\"http://itunes.apple.com/gb/app/paragraft/id412998778?mt=8\">paragraft</a><br><em>less word processor, more plain text</em>";  nsmutabledictionary *resourcedictionary = [nsmutabledictionary dictionary];      [resourcedictionary setobject:[htmlstring datausingencoding:nsutf8stringencoding]  forkey:@"webresourcedata"];  [resourcedictionary setobject:@"" forkey:@"webresourceframename"]; [resourcedictionary setobject:@"text/html" forkey:@"webresourcemimetype"]; [resourcedictionary setobject:@"utf-8" forkey:@"webresourcetextencodingname"]; [resourcedictionary setobject:@"about:blank" forkey:@"webresourceurl"];  nsdictionary *containerdictionary = [nsdictionary dictionarywithobjectsandkeys:resourcedictionary, @"webmainresource", nil];  nsdictionary *htmlitem = [nsdictionary dictionarywithobjectsandkeys:containerdictionary,htmltype,nil];  [pasteboard setitems: [nsarray arraywithobjects: htmlitem, nil]];  // approach draws on blog post , comments at: // http://mcmurrym.wordpress.com/2010/08/13/pasting-simplehtml-into-the-mail-app-ios/ 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -