1

I have a UIView in which I draw with a finger, it all goes fine and dandy, but I need this view to be scrollable. So I made a UIScrollView, and embedded my drawing view in it. But here comes the problem, I can't draw anymore since every tap goes to UIScrollView and it intercepts them for scrolling purposes. What I want to do, is to make UIScrollView only intercept two finger swipes and with single touches and swipes just draw regularly. How do I do that?

I draw by using simpe touchesBegan, touchesMoved methods by using BezierPath, without gesture recognizers.

Dvole
  • 5,725
  • 10
  • 54
  • 87

2 Answers2

3

Check out answer https://stackoverflow.com/a/3173290/1492816 in Scrolling with two fingers with a UIScrollView
People report it as working for the kind of situation you are in.

Community
  • 1
  • 1
Max Huk
  • 498
  • 3
  • 11
  • Yes, I know, sorry. Not enough rep to comment on other's posts yet. – Max Huk Jan 11 '13 at 13:48
  • Ok, but where do I enter such for loop? I declare my scrollView in init of some viewController, and where will my for loop go? – Dvole Jan 11 '13 at 14:04
  • Each UIScrollView needs to be modified only once for this to work, might as well do it right after you create it. Or in viewDidLoad of the relevant controller, if you load from a storyboard – Max Huk Jan 11 '13 at 14:40
0

I have tried this, as suggested in that answer, but to no avail. It says that method recognizePan: is not found. I changed it to nil, and scrolling works with two fingers only as intended, by drawing functionality is missing. I feel like the touches are not getting to my view. What can be done?

UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self.scrollView action:@selector(recognizePan:)];
panGestureRecognizer.maximumNumberOfTouches = 1;
[scrollView addGestureRecognizer:panGestureRecognizer];
Dvole
  • 5,725
  • 10
  • 54
  • 87