I'm using Version 12.0.1 (12A7300). I have some buttons on UIViews and others in UITableViewCells. The actions for the buttons inside table cells are in the parent view controller which I access using protocols. When running the app either on simulators or on my device. All the buttons are added programmatically. The buttons do not work. I reinstalled Xcode Version 11.7 (11E801a) and everything works.
Any way to get around this issue? Is this a bug or did something change and I'm not aware of?
Here is an example of my code. In the UITableViewCell:
var addToCartDelegate: AddToCartDelegate?
let addToCartButton: UIButton = {
let button = UIButton()
return button
}()
let applePayButton: PKPaymentButton = {
let button = PKPaymentButton(paymentButtonType: .buy, paymentButtonStyle: .whiteOutline)
return button
}()
func configureAddToCartButton() {
let button = addToCartButton
button.setTitle("Add To Cart", for: .normal)
button.titleLabel?.font = getScaledFont(forFont: Fonts.bold, textStyle: .body)
button.setTitleColor(Colors.primaryButtonTintColor, for: .normal)
button.tintColor = Colors.primaryButtonTintColor
button.backgroundColor = Colors.primaryButtonBackgroundColor
button.layer.cornerRadius = Attributes.cornerRadius
button.addTarget(self, action: #selector(addToCartButtonWasTapped), for: .touchUpInside)
}
func configureStackView() {
var stackView = UIStackView()
if useApplePay {
stackView = UIStackView(arrangedSubviews: [addToCartButton, applePayButton])
} else {
stackView = UIStackView(arrangedSubviews: [addToCartButton])
}
stackView.axis = .horizontal
stackView.spacing = 16
stackView.distribution = .fillEqually
addSubview(stackView)
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
stackView.heightAnchor.constraint(equalToConstant: 44).isActive = true
stackView.rightAnchor.constraint(equalTo: rightAnchor, constant: -16).isActive = true
stackView.leftAnchor.constraint(equalTo: leftAnchor, constant: 16).isActive = true
}
@objc func addToCartButtonWasTapped() {
addToCartDelegate?.addItemToCart()
}
@objc func applePayButtonWasTapped() {
addToCartDelegate?.buyWithApplePay()
}