0

I was finding ways to calculate FPS as what I said here, holding the idea that when the UITableView scrolls, its drawRect: would be called frame by frame. But it didn't.

The UITableView's drawRect: will be called only once, not matter I drag it up and down quickly or put buttons on it. So does the UITableView's superview and cells. All the UIViews' drawRect:s are called only once for each.

Given that drawRect: called only once, WHO is in charge of refreshing UI/Screen while UITableView's scrolling?

UPDATED 1

I know UITableView's delegate & dataSource are responsible for layout cells to show. But what if tableView just scrolls slightly? Though its delegate & dataSource are not called, the screen's content still changed. On this occasion, who is up to the UI refresh on iPhone screen? scrollView scrolled -> UIKit -> GPU -> LCD Screen?

Community
  • 1
  • 1
Jason Lee
  • 3,200
  • 1
  • 34
  • 71

1 Answers1

1

This is what the UITableView's dataSource and delegate properties are for. They allow you to define who is in charge of setting up the UI and handling user interaction.

Guy Kogus
  • 7,251
  • 1
  • 27
  • 32
  • Thanks for reply. Of course I know UITableView's delegate & dataSource are responsible for layout cells to show. But what if tableView just scrolls slightly? Though its delegate & dataSource are not called, the screen's content still changed. On this occasion, who is up to the UI refresh on iPhone screen? scrollView scrolled -> UIKit -> GPU -> LCD Screen? – Jason Lee Nov 14 '14 at 01:57
  • All iOS UI eventually breaks down to OpenGL ES calls/objects. `UIView`s have their corresponding `CGLayer`s, which get rendered in OES in some way or another. When you change the transform of a view (by translating/moving, rotating, scaling, skewing, etc.) you also update its OES representation. OES will call the drawing method on its objects on each draw loop, which I think is what you're looking for, but it's abstracted away from you. `drawRect:` methods only get called when `setNeedsDisplay` is called, which is minimised for performance sake. – Guy Kogus Nov 14 '14 at 10:37