简体   繁体   English

带有 Swift 的 UITableView 部分页脚文本

[英]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.我想将页脚文本添加到 UITableView 的某些部分。 I know this is easily done when implementing static UITableViews (see image), but I am having difficulty programmatically adding footer text in Swift.我知道这在实现静态 UITableViews 时很容易完成(见图),但我在 Swift 中以编程方式添加页脚文本时遇到了困难。

添加到静态 UITableViewSection 的页脚文本

I am aware of how to add titles to each section.我知道如何为每个部分添加标题。

See the UITableViewDelegate documentation under "Modifying Header and Footer of sections"请参阅“修改节的页眉和页脚”下的 UITableViewDelegate 文档

tableView:viewForFooterInSection:

Asks the delegate for a view object for a view object to display in the footer of the specified section.向委托请求视图对象,以便在指定部分的页脚中显示视图对象。

You need to implement UITableViewDelegate protocol method:你需要实现 UITableViewDelegate 协议方法:

tableView(tableView: UITableView, viewForFooterInSection section: Int)

*Just don't forget to set the delegate first. *不要忘记先设置委托。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM