1

I have this view hierarchy:

enter image description here

the green UIView contains some buttons. the blue UIView is a horizontal UIScrollView.

the problem is here when I swipe on the green view, it captures the swipe and waste it!

How can i forward the gestures from greenView to the blueView (scrollView)? so the blueView can scroll accordingly.

here is the sample. in real greenView background color is clear. for identifying its frame, I colored it green with 0.5 alpha.

https://www.dropbox.com/s/5s3orvpg378dw29/forwardTouchSample.zip?dl=0

Hashem Aboonajmi
  • 13,077
  • 8
  • 66
  • 75
  • Can you elaborate a little further what you want to achieve when the green view is swiped? – S1LENT WARRIOR Oct 04 '14 at 17:47
  • the green view acts like a toolbar. (clear color background. for clearance I colored it green!) it just overlaps the blueView. so the user can see blueView underneath it. the users swipes over it and so the blue view should scroll on that direction. I want to forward swipe gesture from greenView to the blueView. so the blue View can scroll, like there is no greenView. – Hashem Aboonajmi Oct 04 '14 at 18:10
  • the blueView is scrollView with pagination enabled. user slides to see photos. – Hashem Aboonajmi Oct 04 '14 at 18:16
  • i tried replicating your issue, but couldn't do so! Can you help me replicating your issue? – S1LENT WARRIOR Oct 05 '14 at 08:00
  • @S1LENTWARRIOR sample code provided. – Hashem Aboonajmi Oct 05 '14 at 10:07

1 Answers1

0

I've found a solution to your problem.

Try adding Swipe Gestures to your green view and set each gesture's action to select previous/next image.

Append following code into the viewDidLoad of the ViewController class of the sample code that you shared:

UISwipeGestureRecognizer* gesturePrev = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(prev:)];
gesturePrev.direction = UISwipeGestureRecognizerDirectionRight;

[headerVC.view addGestureRecognizer:gesturePrev];

UISwipeGestureRecognizer* gestureNext = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(next:)];
gestureNext.direction = UISwipeGestureRecognizerDirectionLeft;

[headerVC.view addGestureRecognizer:gestureNext]; 

Hope this helps!

S1LENT WARRIOR
  • 11,704
  • 4
  • 46
  • 60
  • thanks for your help. but thats not what Im looking for. as you see, when you scroll, the picture smoothly follows your finger and when reach a point, the picture changes. so here I want as I scroll on the greenView, the scrollView follows my finger,and therefore picture start scrolling. – Hashem Aboonajmi Oct 05 '14 at 16:52
  • Im looking for a way to prevent greenView swallow swipeGesture, so the beneathView can consume it. – Hashem Aboonajmi Oct 05 '14 at 17:00