创建自定义"tickle"的最佳方法是什么? UIGestureRecognizer? [英] What is the best way to create a custom "tickle" UIGestureRecognizer?

查看:260
本文介绍了创建自定义"tickle"的最佳方法是什么? UIGestureRecognizer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为"tickle"创建一个自定义UIGestureRecognizer ...换句话说,检测两次swipeLeft,然后两次swipeRight,而无需抬起手指.

我知道我可以通过使用自定义手势从头开始创建它,但是接下来,我需要实现所有的触摸"方法,并从根本上重新发明滑动手势.是否可以通过组合已有的UIGestureRecognizer来创建自定义UIGestureRecognizer?换句话说,自定义的UIGestureRecognizer可以扩展UISwipeGestureRecognizer吗?

还是我需要从头开始构建它?如果是这样,有人知道滑动手势的底层代码吗?

解决方案

我知道您不愿意从头开始构建它,但是tbh,任何其他方式都会使您感到被黑".

此外,因为从雷·温德利奇(Ray Wenderlich)的手势识别器教程实际讨论了如何实现自己的自定义手势,因此从头开始构建此特定手势将很容易.

这是他的教程的链接: http://www.raywenderlich.com/6567/uigesturerecognizer-tutorial-in-ios-5-pinches-pans-and-more

有关挠痒痒手势的部分朝向底部.随时跟随他的教程并学习如何使用它,或者您可以只下载他的示例代码并复制/粘贴他的痒痒手势识别器类.

糟糕,这个问题已经有好几个月了.哦,好了,现在有答案了.

I would like to create a custom UIGestureRecognizer for a "tickle"... in other words, detecting a swipeLeft followed by a swipeRight, twice, without lifting the finger.

I know I can create it by starting from scratch with a custom gesture, but then I'll need to implement all the 'touches' methods and basically re-invent the swipe gestures. Is there any way of creating a custom UIGestureRecognizer just by combining ones that already exist? In other words, a custom UIGestureRecognizer that extends a UISwipeGestureRecognizer?

Or will I need to build it from scratch? If so, does anyone know the underlying code for a swipe gesture?

解决方案

I know you hesitate to build it from scratch, but tbh, any other way would feel "hacked together".

Besides, building this particular gesture from scratch will be easy because Ray Wenderlich's gesture recognizer tutorial actual talks about implementing your own custom gesture... Now only that, but he shows you how to implement a tickle gesture!

Here's a link to his tutorial: http://www.raywenderlich.com/6567/uigesturerecognizer-tutorial-in-ios-5-pinches-pans-and-more

The part about the tickle gesture is towards the bottom. Feel free to follow his tutorial and learn how to use it, or you can probably just download his sample code and copy/paste his tickle gesture recognizer class.

Edit: Oops, this question is many months old. Oh well, it has an answer now.

这篇关于创建自定义"tickle"的最佳方法是什么? UIGestureRecognizer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆