Question

Is there a way to tell a UITableView to preload all rows?

The tableView is supposed to show several comments (up to 80 comments).

So my CommentCell uses a Setter to adapt the cell to a specific comment.

-(void)setComment:(Comment *)newComment {
 if (newComment != comment) {
     [comment release];
        comment = [newComment retain]; 
       /*
        * set the cells view variables here
        */
    }
}  

This specific setter takes quite a bunch of processing resources and scrolling gets kinda laggy.

I am using a comment-specific reuseIdentifier instead of a static cellIdentifier when calling

dequeueReusableCellWithIdentifier:

in order to assure, that "newComment" equals the old "comment".
And in fact this does work great when scrolling over cells which have already been loaded.

But when scrolling through the comments for the first time, it still lags like hell.

Which leads me to my question:
Is there a way to tell the tableview to preload all cells? (which I doubt)
or
Do I have to implement my own cache instead of relying on "dequeueReusableCellWithIdentifier:"?

Was it helpful?

Solution

Keep in mind that your comment specific reuseIdentifier could be what is causing everything to go slow (or at least, it isn't helping). The reason we use reuseIdentifier for UITableViewCells is because if you try to allocate a new cell every time you need one it isn't as performant as if you can just reuse one that was already made.

I'd recommend pre-computing your comments so you can just set properties of your cells and reusing cells after they scroll off the tableview.

OTHER TIPS

No, you have to preload your data in your dataSource. Just put everything you need in an array and fill the table's cells from that array of preloaded objects.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top