开发者

How should I implement an editable rich document view for the iPhone?

I want to implement a view in an iPhone application that is essentially like a rich text document. I need it to be click-editable, and I'd like to be able to embed graphic objects (either an overlaid view object, or manually drawn in graphic) with the text wrapping around. much like you would expect in a word processor. That's about the minimum functionality needed. Changing font for certain text would be a bonus (bold, size, etc).开发者_Go百科

UITextView would be a great start for me if it supported media like graphics embedded.

I'm still very new to Cocoa and Obj-C. Where should I start?


UITextView will not be nearly sufficient -- it has a very well-defined and simple functionality. That is an extremely complicated thing you're trying to do, wrapping text around an image -- you'll have to use to manually render the text in your drawRect method and do some very complex collision detection and calculate the string sizes etc. It's do-able, but extremely complicated.

Now, if you don't want the text to hug the image, but rather have the two appear on distinct lines, then you could fake this with a UITextView, then a UIImageView, then a UITextView, manually changing size and offset of each as the text changes...but this is a cheap hack and not exactly extensible. It could be sufficient for your needs, however.

UITextView does not allow rich formatting (bold, italics, different sizes, colors...), so that too would require a custom sort of text view.

Basically, it's a pretty big undertaking. If you're really committed, I recommend what Alex said -- get very, very comfortable with UIKit and Objective-C and iPhone coding in general. Then research how to make a rich text editor in other languages more suited to the functionality, and try porting that to the iPhone.

Hope this doesn't sound too discouraging. It's possible, but it won't be easy. And always bear in mind that the iPhone is a phone. Is it really the best platform for your application?


You might start with a much smaller, unrelated project. A viewer is no problem — start with UIWebView, which can render a RTF document for viewing. Creating a document editor, however, is no small task.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜