Post

Replies

Boosts

Views

Activity

Reply to How can I fix action button after update Xcode12?
I am having the same issue. Here is my boiler plate code to recreate it. This is the ViewController Class: import UIKit class SecondScreen: UITableViewController { 		 		private let anotherButtonIdentifier = "AnotherButtonCell" 		 		override func viewDidLoad() { 				super.viewDidLoad() 				 				tableView.register(AnotherCustomCell.self, forCellReuseIdentifier: anotherButtonIdentifier) 		} 		 		override func numberOfSections(in tableView: UITableView) -> Int { 				return 1 		} 		 		override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 				return 1 		} 		 		override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 				 				let cell = tableView.dequeueReusableCell(withIdentifier: anotherButtonIdentifier, for: indexPath) as! AnotherCustomCell 										 				return cell 		} } Here is the custom Cell code: import UIKit class AnotherCustomCell: UITableViewCell { 		 		override func awakeFromNib() { 				super.awakeFromNib() 		} 		 		override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 				super.init(style: style, reuseIdentifier: reuseIdentifier) 				 				self.backgroundColor = .red 				 				let button:UIButton = UIButton(frame: CGRect(x: 0, y: 0, width: 100, height: 50)) 				button.backgroundColor = .black 				button.setTitle("Button", for: .normal) 				button.addTarget(self, action:#selector(self.handleButtonClick(sender:)), for: .touchUpInside) 				self.addSubview(button) 				 		} 		 		required init?(coder: NSCoder) { 				fatalError("init(coder:) has not been implemented") 		} 		 		@objc private func handleButtonClick(sender: UIButton) { 				print("Button click") 		} } I used two simulators. The first one 13.5 works as expected and the console puts out the output. The second simulator with 14.0 doesnt allow me to click the button. Nothing happens. Seems that the button is in the background or something. Any ideas?
Sep ’20
Reply to How can I fix action button after update Xcode12?
@OOPer > As far as I tried, adding this line to init(style:reuseIdentifier:) made the button respond to tap. Code Block > self.contentView.isUserInteractionEnabled = true AWESOME! That fixed the issue for me. In my opinion this seems to be a bug. I tried your code and then looked if they changed the default behavior. Apparently it is already enough to call: print("Userinteraction: \(self.contentView.isUserInteractionEnabled)") By printing out the value, without changing it, already allows me to use the buttons again. Seems like a bug to me, what do you think @OOper?
Sep ’20