4

According to time profile, I found that my app waste too much time on [CALayer layoutSublayers] due to calling [UITable layoutSubviews]. So the action generating tableview is not smooth, whenever tap the button at first time, I would wait almost 2 second until see next view. Each of the cell in the tableview of next view have 8 subview resulting in layoutSubviews engaged too much time. Thus I want to know how to optimize this progress, and I don't want to build a custom cell contain these 8 subviews in its drawrect: to avoid layoutSubviews. Who can help me?

Matt Long
  • 24,438
  • 4
  • 73
  • 99

1 Answers1

1

My guess would be that what you see is a symptom, not the real problem.

I would wait almost 2 second until see next view

What you describe sounds like you would prerender all of the table view's cells (causing massive layout costs) when you first try display it.
Set a breakpoint in cellForRowAtIndexPath:, add a sound action + activate 'Automatically continue after evaluation' to debug this.
It should only get called like 10 times or so (depending on number of rows that are simultaneously visible).

If you are using heightForRowAtIndexPath: on long lists, that may be the source of your problem (depending on your implementation). In that case consider to avoid using it. If you target iOS 7 look into tableView:estimatedHeightForRowAtIndexPath: it might help. (link: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableViewDelegate_Protocol/Reference/Reference.html).

de.
  • 7,068
  • 3
  • 40
  • 69