0

我已经设置了 ECSlidingViewController,如示例中所示。它适用于标准视图控制器没有问题。但是应用程序的主vc具有以下层次结构:

  1. 导航控制器
  2. ContentController 的 UIView
  3. 这个控制器持有一个 UIScrollView 水平分页
  4. 这个 UIScrollView 持有 n UICollectionViewController(s) 和 NBalancedLayout (vertical)

问题是 panGesture 无法识别,因为当我在 scrollView 的第一页上时,我认为向右的另一个手势打开slidingViewController 会起作用?我已经玩过以下方法:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer 
- (BOOL)shouldRequireFailureOfGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
- (BOOL)shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer

我还查看了 ECSlidingViewcontroller wiki - 但还没有找到解决方案:-/。它是应用程序的最后一种 showStopper :-/。

帮助 :-/

这就是我将 panGesture 添加到 contentController 的方式 - 我有一个用于所有 contentController 的基类:

- (void)viewDidLoad

[super viewDidLoad];
// Do any additional setup after loading the view.

self.transitions.dynamicTransition.slidingViewController = self.slidingViewController;

NSDictionary *transitionData = self.transitions.all[0];
id<ECSlidingViewControllerDelegate> transition = transitionData[@"transition"];
self.slidingViewController.delegate = transition;

self.slidingViewController.topViewAnchoredGesture = ECSlidingViewControllerAnchoredGestureTapping | ECSlidingViewControllerAnchoredGestureCustom;
self.slidingViewController.customAnchoredGestures = @[self.dynamicTransitionPanGesture];
[self.navigationController.view addGestureRecognizer:self.dynamicTransitionPanGesture];
4

1 回答 1

1

OK 找到了一个对我来说非常有用的解决方法。我只是在 contentController 的左边缘添加了一个透明视图,我将 panGesture 转发到动态转换委托。如果识别出点击而不是平移 -> 在这种情况下,我要求平移手势识别失败,以捕捉 collectionView 中相应视图上的点击。-> 按预期工作,对可用性没有负面影响。

于 2015-03-02T17:49:34.793 回答