Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Render large size documents in iOS?

I am working on a Reader Project, currently I am parsing the XML file and converted as an attributed string and I render it in CoreText (Used apple Sample Code).

The XML file size is above 6 MB. The texts are rendered correctly, but I can't render the images and Tables (like html tables).

At the same time I need to manage the performance. I have tried UITextView also, but it only displays quarter amount of texts only, after that the text disappears.

Is there any other technology to render texts, images, and tables?

P.S - The Client doesn't want UIWebView.

like image 340
Manimaran Avatar asked Apr 13 '15 06:04

Manimaran


1 Answers

When working on such large files, you may display data in several times. Here are several solutions:

  • Paginate your display by page : split your file into 10 parts (let's say, that's an example) and display with first part in a UITextView. Add two UIButton instances so that the reader can switch page. On page change, load the first/next part into your UITextView. This will not be particularly unfamiliar to users because you're reproducing the natural way they read an e-book. To determine in how many parts you should split your data, keep in eye that the user doesn't want to switch page continuously, you must adjust this with attention.

enter image description here

  • Paginate your display "smoothly": you paginate by page as explained above, but you will always deal with two UITextView embedded in a ScrollView. In the same manner than iOS reuses cells in a UITableView and load cell data on-demand (lazy-loading), implement this reusable mechanism with two UITextView instances - to go quickly, you can try implementing the mechanism with a standard UITableView.

Hope this helps!

like image 175
sweepy_ Avatar answered Oct 17 '22 19:10

sweepy_