My problem is with slow loading, the scrolling speed is fast.
I have to display a table that has 10 columns:
+-----+------+------+------+------+------+------+------+------+-------+
| Pos | Name | Col3 | Col4 | Col5 | Col6 | Col7 | Col8 | Col9 | Col10 |
+-----+------+------+------+------+------+------+------+------+-------+
| 1 | Foo | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 2 | Bar | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 3 | Baz | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
+-----+------+------+------+------+------+------+------+------+-------+
Ignoring the table header (I'm not displaying it) I'm using a UITableView
with a subclassed UITableViewCell
to represent the data.
My custom UITableViewCell
has 10 UILabel
subviews, all added to its' contentView
. One for each column.
I simply set the text value for each UILabel
subview in my cellForRowAtIndexPath
method on the UITableView
.
At any one time there are about 14 rows on the screen. The scrolling is super fast. My reuseIdentifier
is working nicely.
However, the initial load of the table is noticeably slow. A lot slower than my other screens that use a UITableView
but those have substantially less columns.
My cells are all set to opaque
(which I understand is the default anyway).
Is there a trick I'm missing? Are there too many views? Is there another approach I should take? Or is what I'm doing fine and should I be looking for another issue in my code effecting the load time?
Update:
I have run instruments and the bulk of the time (500ms 74.5%) is:
CA::Layer::layout_and_display_if_needed(CA::Transaction*)
Update:
A few people have suggested my data is the bottle neck.
I am using a NSFetchedResultsController
.
There are no calculations. The data for each row is loaded directly from the corresponding Entity and data is displayed as is. I am not walking the object graph to get data from any other relationships or anything like that.
With CoreData SQLDebug
turned on I can see total fetch execution time is 0.0014s for 20 rows. My batch size is set to 20 (slightly more than is visible on screen) to aid in scrolling.
Scrolling is super fast, so I think the data is not the issue here.