开发者

Adding a Target for All UIGestureRecognizers

开发者 https://www.devze.com 2023-03-20 16:26 出处:网络
I am working to integrate a current iOS application with an analytics suite.One of analytics items that we will use in our开发者_如何转开发 UX analysis is a complete track of all gestures (at least on

I am working to integrate a current iOS application with an analytics suite. One of analytics items that we will use in our开发者_如何转开发 UX analysis is a complete track of all gestures (at least ones that are recognized through a UIGestureRecognizer subclass). My goal is to add this hook into the analytics suite without having to subclass each gesture recognizer.

My initial thought was to write a category that had an override for an existing method on UIGestureRecognizer, but I couldn't find a safe way to do that (and I also learned that there is no way to call the class's existing implementation of that method without method swizzling).

My next approach would be to use poseAs and simply have a subclass of UIGestureRecognizer pose as UIGestureRecognizer and add a target on init. However, I then learned that poseAs is deprecated (and has been for a while), so I also abandoned this approach.

Obviously, I could subclass each gesture recognizer we are using, but I feel that doesn't take advantage of the dynamic nature of obj-c.

Is there a good way to accomplish this?


After research, I don't think there is a clean way to do this. I ended up subclassing all of the gesture recognizers to accomplish this shared functionality.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号