开发者

Editable UIWebView in iPhone

I have seen some write about making a UIWebView editable. I would like to be able to compose a message containing both text and images the WYSIWYG way, and I thought that I might do it with a UIWebView.

Is this a good solution and how do I do this? I have searched the web for examples, b开发者_JS百科ut found none.

Thank you


UIWebView content can be made editable starting with iOS 5.0+.

A very nice tutorial can be viewed here: http://ios-blog.co.uk/tutorials/rich-text-editing-a-simple-start-part-1/

The tutorial goes beyond the question, so here's a resume of how to make the UIWebView editable:

//index.html

<html>
 <body>
   <div id="content" contenteditable="true" style="font-family: Helvetica">This is out Rich Text Editing View </div>
  </body>
</html>


//somewhere.m

NSBundle *bundle = [NSBundle mainBundle];
NSURL *indexFileURL = [bundle URLForResource:@"index" withExtension:@"html"];
[webView loadRequest:[NSURLRequest requestWithURL:indexFileURL]];

Anyway, I suggest reading the tutorial, since it shows how to do other stuff as well (changing fonts, colors, embedding images etc.)


You could use the loadHTML:baseURL method from the UIWebView class reference:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWebView_Class/Reference/Reference.html

Place this in the textViewDidEndEditing: delegate method of the UITextView:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UITextView_Class/Reference/UITextView.html


Actually UIWebView way is so painful, mobile safari does not support WYSIWYG rich text editor area.

From Zoho FAQ :

I can't create or edit documents on my iPhone, the keyboard doesn't show up when opening iZoho on iPhone. What's the problem?

It is an issue with the iPhone as the safari browser doesn't seem to recognize the rich text editor area and hence the keyboard isn't appearing. This is not an iZoho specific problem as all the applications that use a WYSIWYG editor face the same issue. We hope that Apple will address this issue soon and come up with the next version of iPhone's Safari that supports rich text editing. As a workaround, we may give a plain text editor for users to edit/create their documents if this isn't corrected in Safari's next version.

You should implement rich text editing by yourself :(

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜