Reputation: 11911
I am using UITableViewController
and I am playing an having multiple sections to my UITableViewController
, I am just curious how do I get headings like Apple Music Search, see screenshot below:
I am talking about the 'Recent' and 'Trending' headings, are those just the section headings or multiple tables?
Upvotes: 0
Views: 410
Reputation: 9355
Use built-in iOS table view section headers. Place your titles in the collection/ array and display it as follows:
let titles = ["Section 1", "Section 2", "Section 3"]
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return titles[Int]
}
Also, you need to define number of sections:
func numberOfSections(in tableView: UITableView) -> Int {
return titles.count
}
Upvotes: 1