UIControl Subclass Not triggering touch events. [iOS]

25 Views Asked by At

I have create a subclass of UIControl, where all the events is working fine when there is no gesture recogniser added to its parent view. But when I add tap gesture to its parent view no events are triggering.

class CustomControl: UIControl {


}

class ViewController: UIViewController {
   @IBOutlet weak var customControl: CustomControl!

    override func viewDidLoad() {
        super.viewDidLoad()
        
        customControl.addTarget(self, action: #selector(didTap(_:)), for: .touchUpInside)
        view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(didTapOnView(_:))))
}

I have tried by alter isUserInteraction property for itself and its subviews but no success. I am not getting any response in didTap(_ sender: Any) method, After adding gesture.

0

There are 0 best solutions below