Monday, November 9, 2026
HomeiOS Developmentios - How you can create extension UITapGestureRecogniazerDelegate or repair overlapping view...

ios – How you can create extension UITapGestureRecogniazerDelegate or repair overlapping view SWIFT

[ad_1]

I create this fundamental faucet gesture operate for dismissing view and I added a delegate to override faucet when the consumer faucets on one other Costume Sheet (container).

@objc func handleTapGesture() {
    dismiss(animated: true, completion: nil)
}

personal func tapGestureToDissmis() {
    let faucet = UITapGestureRecognizer()
    faucet.addTarget(self, motion: #selector(handleTapGesture))
    faucet.delegate = self
    view.addGestureRecognizer(faucet)
} 

extension TextConfigurationVC : UIGestureRecognizerDelegate {
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive contact: UITouch) -> Bool {
    
    if contact.view?.isDescendant(of: container) == true {
        return false
    }
    return true
}

My drawback is that I need to implement this for 8 screens and I do not need to repeat my self. i create in my UIViewcontroler extension file this faucet operate and I do not now easy methods to cross this view :

extension UIViewController : UIGestureRecognizerDelegate {
public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive contact: UITouch) -> Bool {
    if contact.view?.isDescendant(of: **<UIView>)** == true {
        return false
    }
    return true
}

once I created the worldwide container, every time it was known as, it was overlapping one another
(faucet x 6)


[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments