【发布时间】:2019-04-01 14:23:17
【问题描述】:
我添加了带有两个按钮的自定义表格视图标题,但是按钮被禁用,无法进行控制事件。我想得到这样的布局。我是开发新手。任何建议或解决方案
我尝试在 ViewforHeaderSection 函数的视图中添加带有按钮的视图
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let inviteSectionHeaderview = UIView.init(frame: CGRect(x:0, y:0, width: self.view.bounds.width, height: self.view.bounds.height))
let selectAllBtn = UIButton.init(frame:CGRect(x:16, y: inviteSectionHeaderview.bounds.height/2, width:130, height:20))
let sendButton = UIButton.init(frame:CGRect(x:inviteSectionHeaderview.bounds.width - 30, y: inviteSectionHeaderview.bounds.height/2, width:60, height:20))
selectAllBtn.setTitle("select all/Cancel", for: .normal)
selectAllBtn.backgroundColor = .black
sendButton.backgroundColor = .black
sendButton.setTitle("SEND", for: .normal)
self.contactsTable.addSubview(inviteSectionHeaderview)
inviteSectionHeaderview.addSubview(selectAllBtn)
inviteSectionHeaderview.addSubview(sendButton)
return inviteSectionHeaderview
}
【问题讨论】:
-
你能在你目前尝试过的内容上添加代码吗?
标签: ios swift uitableview uitableviewsectionheader