UIWebView Document Behavior Differences
January 02, 2010 Filed in: iPhone
I was trying to decide what document format to use for my help and about app panels. UIWebView is the obvious view of choice to use. UIWebView will display many different document formats, but I considered using 4 different possibilities: PDF, Pages, RTFD, and HTML.
Each document format behaves differently within UIWebView. Below is a summary of some of those differences.
I ended up choosing to work with RTFD for the ease of handling the assets. All images are contained within a single document, it is easily zipped into one file that can be replaced easily, and it's behavior within UIWebView is very predictable with no extra programming.
Each document format behaves differently within UIWebView. Below is a summary of some of those differences.
PDF |
Pages |
RTFD |
HTML |
|
Single File Used? |
Yes - Standard PDF |
Yes - pages.zip or, if later version of pages, the .pages file itself |
Yes - rtfd.zip |
Yes and No - The HTML directory structure is supported. If you want to maintain a single file structure with images, you must use inline images. |
How it looks |
Grey margin around the whole “page” |
Grey margin around the whole “page” |
Fills the page |
Initially fills the page, but can be zoomed with pinch gestures. |
How it Scrolls |
Up/Down & Left/Right |
Up/Down & Left/Right |
Up/Down (& Left/Right once pinch zoom is used) |
Up/Down (& Left/Right once pinch zoom is used) |
What Happens When iPhone is Rotated |
Fonts are maintained in same size, but going from landscape to portrait cuts off some of the document, and from portrait to landscape can add an extra margin to the right of the document. |
Width is adjusted, and fonts are scaled to maintain same relative formatting |
Until pinch zoom is used, the page width automatically adjusts to fill the screen. Once pinch zoom is used, fonts are maintained in same size, but going from landscape to portrait cuts off some of the document, and from portrait to landscape can add an extra margin to the right of the document or even the bottom of the document. |
Similar to RTFD. |
Formatting Richness |
No Limits |
Few Limits |
Somewhat Limited |
Few Limits |
Further Details Worth Mentioning |
Need to manually crop the page height to the amount of data you want to use after generating the PDF. (Preview does this easily.) Pinch zooming did not work for me. |
Page size is defined by the page document format. Pinch zooming works. |
RTF does not appear to directly support hyperlinks, although UIWebView will interpret URLs dynamically. |
Can truly create multiple pages with links to other pages within the document. |