StackoverFlow.
I understand those footer may* have many method to make a label under the cells as known footer.
I know how to create footer with index.row which allow you automatic title, image, and everything with the Arrays, otherwise footer don't?
I am try to make the title under the sections like setting style in iOS 13.
resource code:
When you create an arrays for giving automatic cells.
class SettingViewController: UIViewController {
var settingtitle = ["Item1", "Item2", "Item3"]
var footerTitle = ["Footer1", Footer2", Footer3"]
@IBOutlet weak var TableView: UITableView!
}
Now It's time to build UITableView with Delegate and Data Source.
extension SettingViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return settingtitle.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cells = TableView.dequeueReusableCell(withIdentifier: "Cells", for: indexPath) as? SettingTableViewCell
cells?.Setting_Title.text = settingtitle[indexPath.row]
return cells!
}
}
But How could I uploading the label in the under cells with the array?
I tried many method around stack overflow, but I noticed one of their method has worked but it's show under one footer for whole cells.
thanks you for your helps thought this issues. Let me know if you know.
implement this method:
func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
return footerTitle[section]
}
=== edited ===
If you want to set footer for each cell:
func numberOfSections(in tableView: UITableView) -> Int {
return settingtitle.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cells = TableView.dequeueReusableCell(withIdentifier: "Cells", for: indexPath) as? SettingTableViewCell
cells?.Setting_Title.text = settingtitle[indexPath.section]
return cells!
}
func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
return footerTitle[section]
}