What is the exact order of the UITableViewDelegate methods - weird behavior

I am doing some research to get the tableview delegate methods of the exact order of execution.

Case 1: row count - for small values

So, first I created the lines 100and found the thread of execution as shown below.

  • numberOfSectionsInTableView
  • numberOfRowsInSection
  • cellForRowAtIndexPath

Case 2: the number of rows is above the Int limit

I tried returning a value greater than int limit

Then an exception is found. It works great.

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
 reason: 'Failed to allocate data stores for 402337200000000 rows in section 0.
 Consider using fewer rows'

Case 3: the number of rows is an Int value, but higher

After that, I changed the number of rows to the 4023372000000ideal value, but confirmed the return type of Int.

5 , , . cellForRowAt. . .

= -50 ( ) = 600%

, , .

- ?

3 - , " , ", .

+6
1

: " UITableViewDelegate", , . , :

  • numberOfSectionsInTableView:
  • numberOfRowsInSection:
  • cellForRowAt:

UITableViewDataSource, , . , "" , , 1. : numberOfSectionsInTableView: , , .

2 , tableView . : tableView " " . 1 , 46 . , .

3, , . ? . 468 , , , . , iOS , 32-, 64- .., Apple " " ​​ " , ". , / .

, numberOfRowsInSection cellForRowAt ( )? TableView, , -, .

UITableViewDelegate " ":

  • heightForRowAt:
  • estimatedHeightForRowAt:
  • indentationLevelForRowAt:
  • willDisplay: forRowAt:
  • shouldSpringLoadRowAt: :

, , . , , heightForRowAt cellForRowAt ( , ). , estimatedHeightForRowAt numberOfRowsInSection cellForRowAt.

tableView ? , tableView contentSize: , . estimatedHeightForRowAt, , tableView , , tableView - , : .

, "" , , , tableview " ": , , , , NOT . ...*row*At. Case 2 . cellForRowAt, , , , , . , tableView , ( "dequeued" ) , . , : , .

+5

All Articles