-2

I have a scrollView and it has an imageview. When I disable the user interaction to zoom:

scrollView.gestureRecognizers = false;

And then I want to enable the interactions, the interactions do not work.

And with

scrollView.gestureRecognizers = true;

Is impossible, because this line returns an error.

I'm trying to add the gestures function again but it does not work..

UITapGestureRecognizer *doubleTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(scrollViewDoubleTapped:)];

doubleTapRecognizer.numberOfTapsRequired = 2;
doubleTapRecognizer.numberOfTouchesRequired = 1;

[self.scrollView addGestureRecognizer:doubleTapRecognizer];

How can add the functions again??

Thanks!

gevorg
  • 4,835
  • 4
  • 35
  • 52
user3745888
  • 6,143
  • 15
  • 48
  • 97

2 Answers2

0

This is the declaration for the gestureRecognizers property:

@property(nonatomic,copy) NSArray *gestureRecognizers

It's an array, so it makes no sense that you would set it to true or false.

Just enumerate the array and set the enabled property to each gesture recognizer.

BTW: Setting the property to false works because false and nil are the same.

EmilioPelaez
  • 18,758
  • 6
  • 46
  • 50
0
    maximumZoomScale = self.scrollView.maximumZoomScale;
    minimumZoomScale = self.scrollView.minimumZoomScale;

    self.scrollView.maximumZoomScale = 1.0;
    self.scrollView.minimumZoomScale = 1.0;

and

scrollView.gestureRecognizers = true;

I hope it will help you

Pravin Tate
  • 1,145
  • 8
  • 18
  • scrollView.gestureRecognizers = true; line gets error: implicit conversion 'int' to NSArray is disabled with ARC – user3745888 Jul 23 '15 at 18:11
  • Have you set scrollView content size ? if yes then no need of that line just skip it. and using above line you can disable zooming. – Pravin Tate Jul 23 '15 at 18:13
  • zoom is correct, and ScrollView . gestureRecognizers = false ; i need use this. But then use this only can do double tap gesture – user3745888 Jul 23 '15 at 18:19
  • So set that double tap gesture on image view why you try to set it on scroll view? – Pravin Tate Jul 23 '15 at 18:20
  • I'm using this: http://stackoverflow.com/questions/20165906/how-to-crop-image-inside-the-circle-in-uiimageview-in-ios then I do zoom in a uiscrollView with uiimageView – user3745888 Jul 23 '15 at 18:56
  • So now what is the issue ? – Pravin Tate Jul 23 '15 at 18:57
  • you have reason "So set that double tap gesture on image view why you try to set it on scroll view? " I was setting pinch gesture to view and not to scrollView. thanks! – user3745888 Jul 23 '15 at 19:07