帮帮我。当我点击时我的按钮不起作用,我尝试从堆栈溢出的另一篇文章中尝试其他建议。但没有一个起作用,这是我的代码。
let saveBtn = GActionBtn(type: .system)
lazy var footer: UIView = {
let v = UIView()
v.isUserInteractionEnabled = true
v.addSubview(saveBtn)
saveBtn.isUserInteractionEnabled = true
saveBtn.addTarget(self, action: #selector(handleSave), for: .touchUpInside)
saveBtn.backgroundColor = #colorLiteral(red: 0.4470588235, green: 0.6274509804, blue: 0.3960784314, alpha: 1)
saveBtn.layer.cornerRadius = 27.5
let attributeString = NSAttributedString(string: "Save".localized(), attributes: [NSAttributedString.Key.font: UIFont(name: "NunitoSans-Bold", size: 16), NSAttributedString.Key.foregroundColor: UIColor.white])
saveBtn.setAttributedTitle(attributeString, for: .normal)
NSLayoutConstraint.activate([
saveBtn.centerXAnchor.constraint(equalTo: v.centerXAnchor),
saveBtn.centerYAnchor.constraint(equalTo: v.centerYAnchor, constant: 54),
saveBtn.widthAnchor.constraint(equalToConstant: 312),
saveBtn.heightAnchor.constraint(equalToConstant: 52)
])
return v
}()
@objc private func handleSave() {
print("save")
}
private func setupTableView() {
tableView = UITableView(frame: .zero, style: .grouped)
tableView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 80, right: 0)
tableView.separatorStyle = .none
tableView.keyboardDismissMode = .interactive
tableView.backgroundColor = .white
tableView.tableFooterView = footer
}
设置非零帧/约束为
let v = UIView()
tableView = UITableView(frame: .zero, style: .grouped)