user676446
user676446

Reputation: 13

Scrolling UITableView slow

I have a tableView ,each row has four graphs in it with around 20 rows. As i try to scroll the table i will remove the existing graph and build new graphs for each row.

This operation make the scrolling of the table view very slow. Any ideas to make the scroll faster as well as load new graphs.

Upvotes: 0

Views: 617

Answers (1)

Max MacLeod
Max MacLeod

Reputation: 26652

Creating new views is an expensive operation. That's why it's best to reuse them. You can do this by "dequeueing" existing views to recycle.

Also take a look at Table View Programming Guide for iOS

Specifically, look at the section "Subclassing UITableViewCell" that covers optimisation techniques, e.g.

Draw the entire cell only when appropriate. Your subclass of UITableViewCell could draw all of its content in its drawRect: method, but you should be aware of the potential drawbacks of this approach. Custom drawing applies to the cell’s layer, which can be obscured by any views placed over it. For example, in table views in the grouped style, the background view (the backgroundView property) obscures any drawing performed in drawRect:. The blue selection background will also obscure any drawing. Moreover, custom drawing that occurs during animation (such as when the table view enters and exits editing mode) drastically decreases performance.

Slow table scrolling is a common issue, so you'll be able to find plenty of similar questions covered here on Stack Overflow.

The other thing to consider is that your methods for providing data could be the bottleneck. Instruments will be able to help you identify the issues.

Upvotes: 1

Related Questions