Created
September 25, 2017 02:44
-
-
Save RNHTTR/23742f370b26c0181a56f552b8575020 to your computer and use it in GitHub Desktop.
Determine the title for each section in a UITableView.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use tableView(_:titleForHeaderInSection:) to set the title for each section in a table view. | |
// This example exhibits two instances of this method used in this app. | |
// This demonstrates the use of this method in this app's UITableViewDataSource view controller. | |
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { | |
switch section { | |
case 0: | |
return "Configuring a Table View" | |
default: | |
print("out of index") | |
return "" | |
} | |
} | |
// This demonstrates the use of this method in this app's UITableViewDelegate view controller. | |
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { | |
switch section { | |
case 0: | |
return "Configuring Rows" | |
case 1: | |
return "Managing Selections" | |
case 2: | |
return "Handling Swipe Actions" | |
default: | |
print("out of index") | |
return "" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment