У меня есть UITableView
с пользовательским нижним колонтитулом, установленным в tableFooterView ( не a 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
) отображается внутри UICollectionViewCell
, который занимает весь экран, но позволяет пользователям перемещаться между разделами. Все остальные кнопки внутри таблицы работают нормально.