Daniel Bramhall
Daniel Bramhall

Reputation: 1501

UITableView Section Footer Text with Swift

I have a table view that has a number of sections with varying numbers of rows which have been created dynamically.

I would like to add footer text to certain sections of my UITableView. I know this is easily done when implementing static UITableViews (see image), but I am having difficulty programmatically adding footer text in Swift.

Footer text added to a static UITableViewSection

I am aware of how to add titles to each section.

Upvotes: 0

Views: 2812

Answers (3)

nostoryboardatall
nostoryboardatall

Reputation: 106

func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String?

Upvotes: 1

Azzaknight
Azzaknight

Reputation: 167

See the UITableViewDelegate documentation under "Modifying Header and Footer of sections"

tableView:viewForFooterInSection:

Asks the delegate for a view object for a view object to display in the footer of the specified section.

Upvotes: 0

Matan Lachmish
Matan Lachmish

Reputation: 1263

You need to implement UITableViewDelegate protocol method:

tableView(tableView: UITableView, viewForFooterInSection section: Int)

*Just don't forget to set the delegate first.

Upvotes: 0

Related Questions