I have tableview with custom cells. In custom cell i have View which is Custom UIView class. In this custom UIView class i override touchesBegan and touchesEnded methods to change background color of the custom view when the view is pressed. In tableview cell touchesBegan and touchesEnded methods works perfectly. Background of the view is changing when i pressed tableview cell. But in this case didselectrowat function of tableView is not working. This Custom UiView class cancels didSelectRowat function. Is there any solution of the problem?
Custom class is below:
class BildirisItemBackground: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
self.backgroundColor = UIColor(red: 216/255, green: 216/255, blue: 216/255, alpha: 0.3)
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.05, execute: {
( self.backgroundColor = UIColor(red: 216/255, green: 216/255, blue: 216/255, alpha: 0.0))
})
}
}
And didSelectrowat function:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { print(indexPath.row) }
I expect that printing selected row of tableView. But nothing is printing.