How to make editable WebView on a UITableViewCell?
How can I load local HTML contents to a WebView on UITableViewCell which can be editable too, Such as the mail body of the apple example of the MailComposer. Here we also can get cop开发者_StackOverflow社区y paste and magnifier facilities. Please help me with suggestion or with sample codes. I am warned already to be fired by my company. Please please help me.
With the following assumptions:
- Users do not need advanced editing features (images, bulleted lists, WYSIWYG anything).
- Users do not edit HTML markup.
- The HTML only includes text and basic formatting like linebreaks and indents.
I would suggest:
- Maintain two versions of your HTML content, one that displays in the
UIWebView
and on that the user can edit. The editable one should have all markup tags stripped and, where sensible, replaced with their corresponding plaintext character(s) (so for instance, replace<br>
with\n
). - Load the HTML version of the content into your table as normal (I assume you are already doing this).
- When you table goes into editing more, replace (or overlay) the
UIWebView
with an editableUITextView
populated with your non-HTML version of the content. - When the user indicates they are done editing, take the edited version of the text and invert the replacements you did in step #1 (so for instance, replace every
\n
with<br>
). - Load the modified string you got in step #4 into the UIWebView. Optionally save it to file if you want the app to remember/retain a persistent history of edits to the field.
Although, if the company you are working at thinks that the way to motivate engineers is to threaten them with termination, really you should just thank them for their inept management techniques and be on your way.
精彩评论