将UIPageViewController滑动与iOS 7 UINavigationController反滑动手势相结合 [英] Combine UIPageViewController swipes with iOS 7 UINavigationController back-swipe gesture

查看:168
本文介绍了将UIPageViewController滑动与iOS 7 UINavigationController反滑动手势相结合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个导航控制器,可以推送包含UIPageViewController( PAGES )的视图控制器( PARENT )。现在我使用平移/滑动手势在页面视图控制器的子节点之间切换。但是,我无法再使用屏幕左边框中的滑动手势弹出 PARENT - 视图控制器,因为它被解释为 PAGES 中的手势。

I have a navigation controller that pushes a view-controller (PARENT) that contains an UIPageViewController (PAGES). Now I used pan/swipe gestures to switch between the children of the page-view-controller. However, I can no longer pop the PARENT-view controller using the swipe gesture from the left border of the screen, because it is interpreted as a gesture in PAGES.

当显示最左侧的视图控制器时,是否可以完成刷卡操作?

Is it possible to accomplish that swipe-to-pop when the left-most view-controller is shown?

两个想法:


  1. 中返回nil pageViewtroller:viewControllerBeforeViewController - >不起作用。

  1. Return nil in pageViewController:viewControllerBeforeViewController -> doesn't work.

限制触摸区域,如此处描述

或者有一种更简单的方法吗?

Or is there a more straightforward way?

推荐答案

我和@smallwisdom的情况相同,但处理方式不同。

I had the same situation as @smallwisdom, but handled it differently.

我有一个视图控制器 A ,我在导航控制器的堆栈顶部推动。
此视图控制器 A 包含一个水平滚动视图,从屏幕左侧一直延伸到右侧。

I have a view controller A that I push on top of my navigation controller's stack. This view controller A contains a horizontal scroll view that stretches all the way from left side of the screen to the right.

在这种情况下,当我想从导航控制器的堆栈中将屏幕滑动到弹出视图控制器 A 时,我最后做的就是滚动这个水平滚动查看。

In this scenario, when I wanted to swipe the screen to pop view controller A from navigation controller's stack, all I ended up doing was scrolling this horizontal scroll view.

解决方案非常简单。

我的视图控制器内部 A ,我有这样的代码:

Inside my view controller A, I have code like this:

_contentScrollView = [[UIScrollView alloc] init];
[self.view addSubview:_contentScrollView];
for (UIGestureRecognizer *gestureRecognizer in _contentScrollView.gestureRecognizers) {
   [gestureRecognizer requireGestureRecognizerToFail:self.navigationController.interactivePopGestureRecognizer];
}

效果很好。这是做什么的?
它告诉scrollView的手势识别器,他们必须等待,看看某些其他手势识别器是否会识别当前手势。

It works great. What this does? It is telling the scrollView's gesture recognizers that they have to wait to see if some other gesture recognizer will recognize the current gesture.

如果其他无法识别,那么他们将不再需要等待,他们可以尝试识别当前的手势。

If that other fails to recognize, then they will no longer have to wait and they can try to recognize the current gesture.

如果是其他识别器成功并识别当前手势,然后所有等待的手势识别器将自动失败。

If that other recognizer succeeds and recognizes the current gesture, then all of the gesture recognizers that have been waiting will automatically fail.

其他他们必须等待的手势识别器被设置为导航控制器的interactivePopGestureRecognizer。他负责滑动到后退的手势。

This other gesture recognizer they have to wait is set to be the navigation controller's interactivePopGestureRecognizer. He is in charge for the swipe-to-go-back gestures.

这篇关于将UIPageViewController滑动与iOS 7 UINavigationController反滑动手势相结合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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