Charith Nidarsha
Charith Nidarsha

Reputation: 4245

UITableView scrolling problem

I have a UITableView which reloads every 3 seconds. I reload it only if my Boolean variable is true. In some conditions that variable is always true and that time table is difficult to scroll. (performance is not very good). Other times its ok. What should I do?

Note: I have coded my table according to apple's recommended way(UITableView best practises. Except I add subviews to UITableViewCell, instead drawing on it. I'm confident with other techniques).

What's the solution for this?

Upvotes: 1

Views: 954

Answers (2)

pearl white
pearl white

Reputation: 1

If you are fetching large data set for UITableView, try to fetch the data on need basis. Get the data for each cell in cellForRowAtIndexPath instead of getting all the data for table view and storing.

Upvotes: 0

vodkhang
vodkhang

Reputation: 18741

Are you sure that because you refresh a lot that makes you difficult to scroll. What kinds of refreshing you mean here, refreshing data from network or refresh the table view your cell.

Everytime you refresh your table view or when you scroll the table view, the table view will keep asking for the corresponding cell, and now the whole performance depends on how fast you return the cell.

If you are doing custom UITableViewCell, you are in risk of having a slow performance. Double check these things:

  • Do you reuse your cell correctly? Check if [tableView dequeueReusableCellWithIdentifier:] always return nil or not. If it always return nil, then you do it wrongly.

  • Check if you block the main thread somewhere by loading images from network or file, if it is, using multithread.

  • After you check everything and still has a slow performance, then you either need to reduce the times a cell is returned (by less refreshing) or draw the cell yourself

Upvotes: 2

Related Questions