StackoverFlow。
我知道那些页脚可能*有许多方法可以在单元格下制作标签,称为已知页脚。
我知道如何使用index.row创建页脚,该页脚允许您自动标题,图像以及Arrays的所有内容,否则页脚不这样做?
[我试图在iOS 13中的设置样式等部分下创建标题。
源代码:
[创建用于提供自动单元格的数组时。
class SettingViewController: UIViewController {
var settingtitle = ["Item1", "Item2", "Item3"]
var footerTitle = ["Footer1", Footer2", Footer3"]
@IBOutlet weak var TableView: UITableView!
}
现在是时候使用Delegate和Data Source构建UITableView了。
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!
}
}
但是我如何在带有数组的下单元格中上传标签?
我在堆栈溢出周围尝试了许多方法,但是我注意到他们的一种方法已经奏效,但是整个单元格的页脚显示在一个页脚以下。
感谢您的帮助,认为此问题。如果您知道,请告诉我。
实现此方法:
func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
return footerTitle[section]
}
第一组代表:TableView.delegate =自我
然后添加以下方法:func tableView(_ tableView:UITableView,viewForFooterInSection部分:Int)-> UIView? {让footerView = UIView(frame:CGRect(x:0,y:0,width:tableView.frame.size.width,height:100))footerView.backgroundColor = .green
return footerView
}