I have to show a huge text file in my app.
An UITextView
do not fit my requirements because it forces line wrapping so I had to use an UILabel
. Since very big labels do not get rendered, I'm using several UILabels
inside an UIScrollView
to make it work.
Everything works on the simulator but the required memory for the UILabels
is about 300MB. When I run it on an iPad 2, it gets out of memory and the application crash.
The problem is that I'm not getting any memory warning. I would like to dismiss the view controller in didReceiveMemoryWarning
but it is not been called, the app crashes without any warning.
What am I missing?
Here's an example of using a
UITableView
to solve your problem.HSViewController.h
HSViewController.m
You'll find that there's actually not a big difference in memory usage. The
UITableView
version only saves approx. 10% on memory.However, this is a starting point for dynamically loading up table view cells. So when the user scrolls down (to let's say 90% of the screen) the next X cells can be loaded by changing the return value of
tableView:numberOfRowsInSection:
.Good luck.