How can I speed up a UITableView?

前端 未结 9 1938
广开言路
广开言路 2020-12-22 23:17

I have a UITableView with about 400 cells in 200 sections and it\'s a little sluggish in responding to user interaction (scrolling, selecting cells.) I\'ve made sure the met

9条回答
  •  鱼传尺愫
    2020-12-23 00:02

    1. use a shared image instance for the background (you alloc/init/release one for every time a new cell is created). When your table view is big , this means that the background X cells in memory takes much more memory than it should.

      instead of
      cell.backgroundView= [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cell gradient2.png"]];
      just use :
      cell.backgroundView= [SomeHelperClass sharedBackgroundUIImageResource];

    2. If that doesn't help , use CG instead of labels and other subviews (a screenshot will help here.. to know what we're talking about).

提交回复
热议问题