Bird
0
0

Which UITableViewDataSource method is used to provide a title for a section header?

easy📝 Syntax Q12 of 15
iOS Swift - Lists and Data Display
Which UITableViewDataSource method is used to provide a title for a section header?
AtableView(_:cellForRowAt:)
BtableView(_:titleForHeaderInSection:)
CtableView(_:heightForRowAt:)
DtableView(_:didSelectRowAt:)
Step-by-Step Solution
Solution:
  1. Step 1: Recall UITableViewDataSource methods for headers

    The method tableView(_:titleForHeaderInSection:) returns the text for the header of a section.
  2. Step 2: Differentiate from other methods

    Other methods handle cells, row height, or selection, not headers.
  3. Final Answer:

    tableView(_:titleForHeaderInSection:) -> Option B
  4. Quick Check:

    Header title method = tableView(_:titleForHeaderInSection:) [OK]
Quick Trick: Header titles use titleForHeaderInSection method [OK]
Common Mistakes:
  • Choosing cellForRowAt for headers
  • Confusing heightForRowAt with header titles
  • Selecting didSelectRowAt which is for taps

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes