Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在表视图中将节页脚粘贴在一个特定页脚的末尾_Ios_Swift_Header_Tableview_Footer - Fatal编程技术网

Ios 如何在表视图中将节页脚粘贴在一个特定页脚的末尾

Ios 如何在表视图中将节页脚粘贴在一个特定页脚的末尾,ios,swift,header,tableview,footer,Ios,Swift,Header,Tableview,Footer,我有一些章节在这里和第1节,我有这个页脚作为一个额外的信息。 但当我滚动屏幕时,它一直在浮动。我怎样才能阻止它?我如何将其保存在该部分下? 我使用的是viewforfooterInstition,下面是我的代码: override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { let footerView = UIView() if sec

我有一些章节在这里和第1节,我有这个页脚作为一个额外的信息。 但当我滚动屏幕时,它一直在浮动。我怎样才能阻止它?我如何将其保存在该部分下? 我使用的是
viewforfooterInstition
,下面是我的代码:

override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
    let footerView = UIView()
    if section == 1 {
        let label = UILabel()
        label.text = "A sticky footer here..."
        label.font = .systemFont(ofSize: 16)
        label.textColor = UIColor.gray
        label.backgroundColor = UIColor.clear
        label.textAlignment = .left
        footerView.addSubview(label)
        label.translatesAutoresizingMaskIntoConstraints = false
        label.topAnchor.constraint(equalTo: footerView.topAnchor, constant: 10).isActive = true
        label.leftAnchor.constraint(equalTo: footerView.leftAnchor, constant: 20).isActive = true
        label.rightAnchor.constraint(equalTo: footerView.rightAnchor).isActive = true
        label.bottomAnchor.constraint(equalTo: footerView.bottomAnchor).isActive = true
    }
    return footerView
}
我想让它保持粘性,在我的第一部分。我该怎么做

先谢谢你


您应该使用分组样式初始化表视图


让tableView=UITableView(frame:.zero,style:.grouped)

如果我没有弄错的话,您的
UITableView
应该是分组样式,以便使页脚粘在节上并随节一起移动,我应该将此代码放在哪里?我把它放在了
ViewDidLoad()
中,但没有起作用,很可能超出了该函数的范围。如果您使用的是interface builder,则可以从属性面板将样式设置为.grouped。我知道您要做什么了,伙计,谢谢您的帮助!