ECSlidingViewController with UIScrollView

129 Views Asked by At

I have setup the ECSlidingViewController as shown in the examples. It works without problems for standard viewControllers. But the main vc of the app has the following hierarchy:

  1. NavigationController
  2. UIView of ContentController
  3. this controller holds a UIScrollView with paging horizontally
  4. this UIScrollView holds n UICollectionViewController(s) with NHBalancedLayout (vertical)

The problem is that the panGesture is not recognized because when I am on the first page of the scrollView I thought it will just work that another gesture to the right opens the slidingViewController? I have already played around with methods like:

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

I also took a look at the ECSlidingViewcontroller wiki - but did not find a solution there yet :-/. Its the last kind of showStopper for the app :-/.

Help :-/

Thats how I add the panGesture to the contentController - I have a baseClass for all contentControllers:

- (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];
1

There are 1 best solutions below

2
On

OK found a workaround which works quite nice for me. I just add a transparent view at the left edge of the contentController where I forward the panGesture to the dynamic transition delegate. If a tap is recognized instead of pan -> I am requiring the pan gesturerec to fail in this case to catch the tap on the corresponding view in the collectionView. -> works as expected and does not have negative effects concerning usability.