开发者

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:

  1. Users do not need advanced editing features (images, bulleted lists, WYSIWYG anything).
  2. Users do not edit HTML markup.
  3. The HTML only includes text and basic formatting like linebreaks and indents.

I would suggest:

  1. 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).
  2. Load the HTML version of the content into your table as normal (I assume you are already doing this).
  3. When you table goes into editing more, replace (or overlay) the UIWebView with an editable UITextView populated with your non-HTML version of the content.
  4. 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>).
  5. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜