views:

80

answers:

2

Hi all,

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?

+2  A: 

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

vodkhang
Yes I stream data from a socket connection and refresh my table data. (using [table reladData]; I measured the performance through instruments. It doesnt show memory growing when scrolling and no leaks there.1. Answer is YES.2. MY app app is a mutithreaded application and I updated the other view's UI on the main thread(using performSelectorOnMainThread). May this be the reason?
charith
Memory leak is usually not a big deal for performance (even it can cause crashes). What you mean by other view' UI? Is it your table view cell UI? Or other UI? Usually, scrolling requires a lot of cpu processing so that try not to use the main thread for something else except return the cell as fast as possible
vodkhang
but even in that case, the performance may still be slow if you add many subview (especially image), then you have no other choice except drawing cell
vodkhang
Thanks for your comments vodkhang. I mean the other UIViews in my iPad application. User can see 2 tables at once.
charith
Is there a way to update only the Visible views in the application. I have several views that updated within several threads
charith
I am not sure about iPad because I mainly work in iPhone:). Do you have UINavigationController there, if you have then the top view is the visible view
vodkhang
A: 

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.

pearl white