5

I am loading an HTML in my UIWebView. Now I want a user to allow editing this HTML if he wants. Basically it is an email functionality and my body is in HTML format so I render it a UIWebView which works fine. Now if a user wants to reply to this mail, I would like to give him the ability to edit the HTML formatted body. I read something about HTML 5 content editable property but that doesn't seem to help. How can I accomplish it using UIWebView? I have seen the native iphone mail client implementing this functionality.

If there is no other way and I am forced to use MFMailComposeViewController, can I use MFMailCompose View controller to send mails to my own server or for that matter any server?

2 Answers 2

8

You can edit the format of the document in a UIWebView through Javascript using the method:

- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script;

For example to change the body background do:

[_webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body').style.backgroundColor='#FFFFFF'"];
1
  • How does this allow a user to edit content within a UIWebView? Dec 22, 2014 at 21:45
1

Using MFMailComposeViewController should be the easiest solution to your problem. As for the To: address, simply set the view controller's recipients using - (void)setToRecipients:(NSArray*)toRecipients.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.