【问题标题】:Swift:remove space below footer of tableview controller embedded in navigation controllerSwift:删除嵌入在导航控制器中的表格视图控制器页脚下方的空间
【发布时间】:2020-07-09 07:35:12
【问题描述】:

我只想删除页脚视图下方的空间。它显示在所有版本的 iPhone 11 上。我希望我的页脚始终显示在屏幕上,而不是在部分单元格的末尾。screenshot of my tableview controller

这是我的代码

override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        let footer=tableView.dequeueReusableHeaderFooterView(withIdentifier: "footerCell") as! FooterCell
        return footer
    }
class FooterCell:PostSectionBase{

    lazy var button:UIButton={
            let button=UIButton()
                     button.layer.cornerRadius=10
                     button.layer.borderColor=UIColor(red: 59/255, green: 178/255, blue: 250/255, alpha: 1).cgColor
                     button.layer.borderWidth=1
        button.backgroundColor=UIColor(red: 59/255, green: 178/255, blue: 250/255, alpha: 1)
                     button.setTitle("Confirm", for: .normal)
                     button.titleLabel?.font=UIFont.init(name: "HelveticaNeue-Bold", size: 19)
                     button.titleLabel?.adjustsFontSizeToFitWidth = true
                     button.titleLabel?.minimumScaleFactor = 0.5
        button.setTitleColor(UIColor.white, for: .normal)
                     return button
        }()

    override func setupViews(){
        setupContainerView()
    }
    func setupContainerView(){
        addSubview(button)
        addConstraintsWithFormat(format: "H:|-40-[v0]-40-|", views: button)
        addConstraintsWithFormat(format: "V:|-40-[v0(40)]-40-|", views: button)
    }
}

【问题讨论】:

    标签: ios swift uitableview footer


    【解决方案1】:

    实现这一点的一种方法是制作一个 UIViewController。然后添加 tableView 作为它的子视图。您还可以将页脚视图添加为 ViewController 的视图而不是 tableView 的子视图。它工作正常。

    【讨论】:

      猜你喜欢
      • 2017-10-24
      • 2018-11-09
      • 1970-01-01
      • 2018-07-23
      • 1970-01-01
      • 2014-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多