OStack程序员社区-中国程序员成长平台

标题: iOS 11 - 基于触摸类型的 HitTest [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 20:16
标题: iOS 11 - 基于触摸类型的 HitTest

快速提问:有没有一种简单的方法可以在 UIView 中使用触摸信息进行测试?我有一个需要铅笔来响应的 UIView,我有另一个需要手指来响应的 UIView (PDFView) 我想要一种基于触摸类型将触摸转发到每个 View 的方法。想法?



Best Answer-推荐答案


你可以使用UIResponder的方法touchesBegan(_:with:https://developer.apple.com/documentation/uikit/uiresponder/1621142-touchesbegan

UITapGestureRecognizer:https://developer.apple.com/documentation/uikit/uigesturerecognizer/1620009-touchesbegan https://developer.apple.com/documentation/uikit/uigesturerecognizerdelegate/1624214-gesturerecognizer

您可以从 UITouch 对象获取的有关触摸类型的信息:https://developer.apple.com/documentation/uikit/uitouch/touchtype

关于iOS 11 - 基于触摸类型的 HitTest ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51028156/






欢迎光临 OStack程序员社区-中国程序员成长平台 (http://ostack.cn/) Powered by Discuz! X3.4