`touchesBegan:withEvent:` is delayed at left edge of screen

后端 未结 5 1419
余生分开走
余生分开走 2021-01-06 03:38

I\'m experiencing an issue where the first call to touchesBegan:withEvent: on a UIView or UIViewController is delayed when you touch o

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-06 03:57

    This works for me

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
    
        if let window = view.window,
            let recognizers = window.gestureRecognizers {
            recognizers.forEach { r in
                r.delaysTouchesBegan = false
                r.cancelsTouchesInView = false
                r.isEnabled = false
            }
        }
    }
    

提交回复
热议问题