MonoTouch:如何向 UIPageViewController 添加两指手势识别器?

发布于 2024-12-17 10:06:34 字数 372 浏览 0 评论 0原文

具有 PageCurl 过渡的 UIPageViewController 非常适合模拟页面,但默认的 GestureRecognizer (UIPanGestureRecognizer) 仅响应一根手指事件。我想在其他事件之上添加一个两指事件。

如何向当前 UIPageViewController 实例添加另一个 PanGestureRecognizer?这个新的 PanGestureRecognizer 应等待两个手指平移触摸,而不禁用原始的 UIPanGestureRecognizer。

我所需要的只是一种方法,如果用户用两根手指而不是一根手指滚动页面,但它仍然应该像调用单指事件一样滚动页面。

我怎样才能在 MonoTouch 中做到这一点?

提前致谢。

The UIPageViewController with the PageCurl transition is great for simulate pages, but the default GestureRecognizer (UIPanGestureRecognizer) is only responding to one finger events. I want to add a two finger event above the others.

How to add another PanGestureRecognizer to the current UIPageViewController instance? This new PanGestureRecognizer should wait for two fingers pan touches, without disabling the original UIPanGestureRecognizer.

All I need is a way to rise an additional custom event if the user scroll the pages with two fingers instead of one, but it should still scroll the pages like the one finger event was called.

How can I do this in MonoTouch?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

随梦而飞# 2024-12-24 10:06:34

我自己解决了这个问题。 UIPageViewController 包含一组手势识别器。第一个是我们需要获取的,将其“MaximumNumberOfTouches”属性从 1 更改为 2。代码如下:

UIPageViewController pageController = new UIPageViewController (UIPageViewControllerTransitionStyle.PageCurl, UIPageViewControllerNavigationOrientation.Horizontal, UIPageViewControllerSpineLocation.Min);

UIPanGestureRecognizer pan_gesture_recognizer = (UIPanGestureRecognizer) pageController.GestureRecognizers[0];

pan_gesture_recognizer.MaximumNumberOfTouches = 2;

然后,在处理翻页事件的代码中(在我的例子中是继承“UIPageViewControllerDataSource”的自定义类)您可以通过以下方式访问当前的触摸次数:

int number_of_touches = pageController.GestureRecognizers [0].NumberOfTouches;

并使用该值进行相应的操作。

I solved the issue myself. The UIPageViewController contains an array of gesture recognizers. The first one is the one we need to get, changing its "MaximumNumberOfTouches" property from 1 to 2. Here is the code:

UIPageViewController pageController = new UIPageViewController (UIPageViewControllerTransitionStyle.PageCurl, UIPageViewControllerNavigationOrientation.Horizontal, UIPageViewControllerSpineLocation.Min);

UIPanGestureRecognizer pan_gesture_recognizer = (UIPanGestureRecognizer) pageController.GestureRecognizers[0];

pan_gesture_recognizer.MaximumNumberOfTouches = 2;

Then, inside your code handling the page turn event (in my case a custom class inheriting the "UIPageViewControllerDataSource") you can access the current number of touches with:

int number_of_touches = pageController.GestureRecognizers [0].NumberOfTouches;

and use this value to act accordingly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文