ios - 如何在 UITableView 中制作最后的页脚?

标签 ios swift uitableview footer

我尝试在 UITableView 中创建页脚,就像在 iOS 应用“联系人”中一样。

enter image description here

我有简单的 tableView 和简单的数组: items = ["aa", "bb", "cc", "dd"] 我想在最后一个单元格下留出空间。

我尝试添加此 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
    }

这个方法看起来不错,但是它在最后一个单元格下面丢失了分隔符... enter image description here

最佳答案

您应该创建一个 UIView 并将其分配给表格的页脚 View

myTableView.tableFooterView = createTableFooterView()

func createTableFooterView() -> UIView {
    let footerView = UIView()
    ...
    ...
    ...
    return footerView
}

关于ios - 如何在 UITableView 中制作最后的页脚?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48316497/

相关文章:

ios - 以编程方式将 View 的前缘与约束对齐

ios - 在iOS中单击UITableViewCell后如何获取字典中的键值?

ios - 使用 AVPlayerViewController 从 HTTP 实时流中获取视频详细信息

IOS Swift 表格 View : Is there a way to move first cell one row down

ios - 将排序后的数据管理到 TableViewController 中的索引部分和单元格中

iphone - 自动与中央数据库同步

iphone - 如何从 UITextView 获取选定的文本框

javascript - iOS swift : When I pass data like array or dictionary to Javascript means it returns Undefined value?

xcode - UISearchController 不更新

iphone - 更改 UITableViewCell 中的删除附件 View