Ios 如何在UITableView中生成最终页脚?
我尝试在UITableView中创建页脚,就像在iOS应用程序“联系人”中一样 我有带简单数组的简单tableView: 项目=[“aa”、“bb”、“cc”、“dd”] 我想在最后一个牢房下面腾出一个空间 我试图添加此Ios 如何在UITableView中生成最终页脚?,ios,swift,uitableview,footer,Ios,Swift,Uitableview,Footer,我尝试在UITableView中创建页脚,就像在iOS应用程序“联系人”中一样 我有带简单数组的简单tableView: 项目=[“aa”、“bb”、“cc”、“dd”] 我想在最后一个牢房下面腾出一个空间 我试图添加此cellForRowAt: if indexPath.row == self.converterItems.count-1 { cell.separatorInset = UIEdgeInsetsMake(0, cell.bounds.size.width, 0, 0)}
cellForRowAt
:
if indexPath.row == self.converterItems.count-1 {
cell.separatorInset = UIEdgeInsetsMake(0, cell.bounds.size.width, 0, 0)}
但它只删除一个单元格的分隔符
override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
var header :UITableViewHeaderFooterView = UITableViewHeaderFooterView()
header.contentView.backgroundColor = UIColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1)
return header
}
此方法看起来不错,但它在最后一个单元格下面丢失了分隔符。。。
您应该创建一个
ui视图
,并将其分配给表的页脚视图
myTableView.tableFooterView = createTableFooterView()
func createTableFooterView() -> UIView {
let footerView = UIView()
...
...
...
return footerView
}
让桌子变得无穷无尽。您最好设置
UITableViewStyle.grouped
let tableView = UITableView(frame: CGRect.zero, style: .grouped)
然后:
extension ViewController: UITableViewDelegate, UITableViewDataSource{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return [].count// your array
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "", for: indexPath)
// your cell
// yourIdentifier, and you should register cell Identifier for tableView at first
return cell
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return CGFloat.leastNormalMagnitude
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return ""
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 50
}
func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
return "83 KOH"
}
}
您的意思是将83kohtakta标签作为页脚??tableview有什么问题。tableFooterView?是。此单元格统计联系人总数,并且自身下没有任何内容。我只是把它拖上去)@IvanKisin你试过tableFooter视图了吗。另外,请解释一下你们都尝试了些什么,以便我们能更好地帮助你们。@PallaviSrikhakollu更新了主题。它的“添加页脚”,但我如何才能让它永无止境?