0
0
iOS Swiftmobile~5 mins

Section headers and footers in iOS Swift - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of section headers in a UITableView?
Section headers help group related rows visually and provide a title or description for each group, making the list easier to understand.
Click to reveal answer
intermediate
Which UITableViewDelegate method provides a view for a section header?
tableView(_:viewForHeaderInSection:) returns a UIView to display as the header for a given section.
Click to reveal answer
intermediate
How do you set the height of a section footer in a UITableView?
Implement tableView(_:heightForFooterInSection:) in UITableViewDelegate and return the desired height in points.
Click to reveal answer
beginner
True or False: Section footers can only display text, not custom views.
False. Section footers can display custom views by implementing tableView(_:viewForFooterInSection:).
Click to reveal answer
intermediate
What happens if you return nil from tableView(_:viewForHeaderInSection:)?
The table view will display the default header, which can be a simple text label if you provide a title via tableView(_:titleForHeaderInSection:).
Click to reveal answer
Which method sets the text title for a section header in UITableView?
AtableView(_:titleForHeaderInSection:)
BtableView(_:viewForHeaderInSection:)
CtableView(_:heightForHeaderInSection:)
DtableView(_:titleForFooterInSection:)
How can you provide a custom view for a section footer?
AImplement tableView(_:titleForFooterInSection:)
BImplement tableView(_:viewForFooterInSection:)
CImplement tableView(_:heightForHeaderInSection:)
DImplement tableView(_:cellForRowAt:)
What delegate method controls the height of a section header?
AtableView(_:titleForHeaderInSection:)
BtableView(_:heightForFooterInSection:)
CtableView(_:estimatedHeightForRowAt:)
DtableView(_:heightForHeaderInSection:)
If you want no header for a section, what should you return from tableView(_:heightForHeaderInSection:)?
A0
BCGFloat.leastNormalMagnitude
CUITableView.automaticDimension
D-1
Which of these is NOT a valid way to customize section headers?
AProviding a title string
BReturning a custom UIView
CModifying the cellForRowAt method
DChanging the header height
Explain how to add a custom view as a section header in a UITableView.
Think about which delegate method returns a UIView for the header.
You got /3 concepts.
    Describe the difference between providing a title and a custom view for section footers.
    One is simple text, the other is a full view.
    You got /3 concepts.