I have one tableview and each cell contains one button. It\'s working pretty well all iOS versions but 7. I don\'t know what\'s going on. The cell is constructed in one xib
In Swift 5, I create a class UITableViewCell and I create a UIButton.
class DashboardingGameTableViewCell: UITableViewCell {
// MARK: Setup Views
var showInteractiveButton: UIButton = {
let interactive = UIButton()
interactive.setTitle("", for: .normal)
interactive.contentEdgeInsets = UIEdgeInsets(top: 10.0, left: 10.0, bottom: 10.0, right: 10.0)
interactive.setImage(UIImage(systemName: "ellipsis"), for: .normal)
interactive.tintColor = .white
interactive.backgroundColor = .clear
interactive.translatesAutoresizingMaskIntoConstraints = false
return interactive
}()
...
and on my
class DashboardingGameViewController: UIViewController, UITableViewDelegate, UITableViewDataSource...
The UIButton was not clickable
for It works I have to make...
on DashboardingGameViewController: UITableViewCell...
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
contentView.isUserInteractionEnabled = false
addSubview(showInteractiveButton)
...
on DashboardingGameViewController: UIViewController, UITableViewDelegate, UITableViewDataSource...
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: reusableIdentifier,
for: indexPath) as! DashboardingGameTableViewCell
cell.showInteractiveButton.addTarget(self, action: #selector(interactiveGames(_:)), for: .touchUpInside)
...
// MARK: - Private Funcs
@objc private func interactiveGames(_ button: UIButton) {
present(ShowInteractiveGameViewController(), animated: true, completion: nil)
}