[英]set button on bottom of static tableView
hello I want to set the programmatically created button at bottom of static tableView
. 你好,我想在静态
tableView
底部设置以编程方式创建的按钮。 The problem I am having is the botton stays at the bottom on smaller phones(5s) which is completely fine. 我遇到的问题是在较小的手机(5s)底部保持底部,完全没问题。 But on 6s Plus it shows white area underneath the button.
但是在6s Plus上,按钮下方显示白色区域。 Meaning the button is slightly above from the ground or above from edge of the bottom.
这意味着按钮略高于地面或从底部边缘的上方。
This is how I am setting the button 这就是我设置按钮的方式
func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView?
let footerView = UIView()
footerView.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 50)
footerView.backgroundColor = UIColor.redColor()
let buttonNext = UIButton(type: UIButtonType.System)
buttonNext.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 50)
buttonNext.translatesAutoresizingMaskIntoConstraints = false
buttonNext.setTitle("NEXT", forState: UIControlState.Normal)
buttonNext.backgroundColor = UIColor.blueColor()
footerView.addSubview(buttonNext)
footerView.layoutIfNeeded()
return footerView
}
func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 50
}
It sounds like you want a footer at the bottom of the table, rather than at the end of the section. 听起来您想在表的底部而不是本节的末尾添加页脚。 In this case you should use the table's
tableFooterView
property. 在这种情况下,您应该使用表的
tableFooterView
属性。 You could do this with the following code in viewDidLoad
(or elsewhere): 您可以在
viewDidLoad
(或其他地方)中使用以下代码来执行此操作:
let footerView = UIView()
footerView.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 50)
footerView.backgroundColor = UIColor.redColor()
let buttonNext = UIButton(type: UIButtonType.System)
buttonNext.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 50)
buttonNext.translatesAutoresizingMaskIntoConstraints = false
buttonNext.setTitle("NEXT", forState: UIControlState.Normal)
buttonNext.backgroundColor = UIColor.blueColor()
tableView.tableFooterView = footerView
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.