Skip to content

Instantly share code, notes, and snippets.

@simonpang
Last active February 2, 2018 08:54
Show Gist options
  • Save simonpang/cdcf806420a7b49fc0f02f1d83fd6d84 to your computer and use it in GitHub Desktop.
Save simonpang/cdcf806420a7b49fc0f02f1d83fd6d84 to your computer and use it in GitHub Desktop.
Debug UIEvent
override func sendEvent(_ event: UIEvent) {
NSLog("sendEvent \(event)")
super.sendEvent(event)
var vc = keyWindow!.rootViewController!
while vc.presentedViewController != nil {
vc = vc.presentedViewController!
}
// Find hit view
if let view = vc.view {
if let t = event.allTouches?.first {
let p = t.location(in: view)
if let hitView = view.hitTest(p, with: event) {
NSLog("hit view = \(hitView)")
}
}
}
}
@simonpang
Copy link
Author

Then debug view hierarchy in Xcode, filter view using the memory address of the hit view.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment