我有UITableView
一个自定义页脚设置为tableFooterView(不是sectionFooter )。我这样做是这样的:
override init(frame: CGRect) {
super.init(frame: frame)
setupViews()
MyTableView.tableFooterView = tableFooter
MyTableView.tableFooterView?.addSubview(nextButton)
}
var tableFooter: UIView = {
let tableFooter = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 64)
tableFooter.backgroundColor = .white
tableFooter.isUserInteractionEnabled = true
return tableFooter
}()
var nextButton: UIButton = {
let nextButton = UIButton(frame: CGRect(x: normalSpacing, y: 0, width: UIScreen.main.bounds.width - 32, height: 64)
nextButton.backgroundColor = UIColor.green
nextButton.setTitle("Next", for: .normal)
nextButton.titleLabel?.font = UIFont.boldSystemFont(ofSize: 12)
nextButton.setTitleColor(UIColor.white, for: .normal)
nextButton.setTitleColor(UIColor.white.withAlphaComponent(0.75), for: .selected)
nextButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
nextButton.layer.cornerRadius = 20
nextButton.isUserInteractionEnabled = true
nextButton.addTarget(self, action: #selector(nextAction), for: .touchUpInside)
return nextButton
}()
@objc func nextAction() {
print("Next tapped")
}
现在,该按钮可见并出现在我希望按钮所在的位置。我还可以设置背景颜色,它出现在按钮的正后方,所以我不认为框架是这里的问题(因为关于这个问题有很多类似的问题)。如我错了请纠正我。我在我认为需要启用的任何地方都启用了用户交互。
关于如何解决这个问题的任何想法?我已经尝试了几乎所有东西,但我似乎无法弄清楚。所有这些(UITableView
)都显示在 aUICollectionViewCell
中,它占据了整个屏幕,但允许用户在各个部分之间滑动。表格内的所有其他按钮都可以正常工作。