How to debug who is eating my touches in UIKit?

前端 未结 7 1494
孤街浪徒
孤街浪徒 2021-01-30 17:16

I can\'t figure out why tapping on text fields and buttons in my view is not working. I\'ve checked all the obvious things like whether userInteractionEnabled is set to YES, whe

7条回答
  •  梦如初夏
    2021-01-30 17:38

    My full Swift Example following @Bryan Chen and @kelin Answer ...

    import UIKit
    
    @UIApplicationMain
    class AppDelegate: UIResponder, UIApplicationDelegate {
        var window: UIWindow? = TestWindow()
        // ....
    }
    
    ...
    
    class TestWindow:UIWindow {
        override func sendEvent(_ event: UIEvent) {
    
            print(event)
    
            // timestamp: 366545 touches: {(
            //     phase: Ended tap count: 1 force: 0.000 
            //window: ; 
            //layer = > view: ; layer = > location in 
            //window: {165, 358.33332824707031} previous location in window: 
            //{144.33332824707031, 358.66665649414062} location in view: {165, 
            //44.999992370605469} previous location in view: {144.33332824707031, 
            //45.333320617675781}
            //    )}
    
            super.sendEvent(event)
        }
    }
    

提交回复
热议问题