How to Implement a Rich Document Editor for iPhone

I am just starting out on a new iPhone / iPad development project and I need to display a document with rich styled text (possibly with inline images). The user touches the document by dragging and dropping to select single words or multi-line text. When the text is highlighted, a context menu will appear allowing them to change the highlight color or add bullet notes (or other various bits of structured metadata).

If you are familiar with adding comments to a Word document (or annotating a PDF file), then this is the same. But in my case, a typical user would spend many hours in an application adding thousands (in some cases, tens of thousands) of small annotations to the central document. All of these bits of metadata will be stored locally pending synchronization with the remote web service.

I've read other tips where developers suggest creating a UIWebView control and passing an HTML string to it. But that seems pretty awkward, especially with all the context sensitivity I want to include.

Anyway, I'm new to iPhone and Objective-C development, although I have ten years of software development experience using different languages ​​on different platforms, so I don't worry about getting my hands dirty with new functionality from scratch.

But if anyone has experience creating a similar component, I am interested in learning strategies for including this kind of markup and document annotation.

+2


a source to share


3 answers


With iPad, you can use Body Text .



Not sure what to suggest for iPhone. I haven't noticed any great word processing in any iPhone reading apps other than HTML or PDF rendering. I suspect you will have to write something from scratch.

+2


a source


I am working on a simplified version of what you are describing. For ease of implementation, I've limited it to drill down to detail, so long press selects a paragraph and then a list of options to apply to the paragraph appears.

I am doing all this in javascript inside a UIWebView. This was my last choice on how to make a text editor. I had to be backward compatible (no CoreText) and release via iTunes (no personal WebKit), so I was left with javascript.

You might, perhaps, achieve what you want using this very clumsy method. Javascript works best at the element level, so you probably want to wrap every word in the document in between with a unique ID.



Javascript has full access to touch events, gestures, and the DOM. It controls the UIWebView better than what you get from Cocoa's side. You can get a bi-directional communication path with the host application with some tricks. PhoneGap has a good implementation.

If you have a choice to do it differently, I would take that option. If you're stuck like me, this is a viable albeit frustrating option.

+2


a source


If you're ready to work with iPhone OS 3.2 or higher, you may need to check out the latest version of the Omni Group for the latest version of their open source framework . It includes a sample rich text editor based on body text.

+1


a source







All Articles