1

Hi I have a UIScrollView inside of a UIView. I have tried to use code snippets that I found online but they simply don't change anything. Also they are mostly for an image or custom view done within UIView, whereas in my case I have an array of programatically created UILabels. I have tried to change boundary values as well, it simply does not do anything. This is basically how I establish the size of it within viewDidAppear:

[scrollView setContentSize:CGSizeMake([screenView getWidth], [screenView getHeight])];


scrollView.showsHorizontalScrollIndicator = true;
scrollView.showsVerticalScrollIndicator = true;

screenView is a UIView variable.

This is the settings that I use(also in viewDidAppear):

doubleTapRecogniser = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTapResponse:)];
    [doubleTapRecogniser addTarget:self action:@selector(doubleTapResponse:)];


    doubleTapRecogniser.delegate = self;

    doubleTapRecogniser.numberOfTapsRequired = 2;

    [self.scrollView addGestureRecognizer:doubleTapRecogniser];

This is how I implemented my double tap method:

- (void) doubleTapResponse:(UITapGestureRecognizer *)recogniser
{

    CGFloat newZoomScale = self.scrollView.zoomScale / 1.5f;
    newZoomScale = MAX(newZoomScale, self.scrollView.minimumZoomScale);
    [self.scrollView setZoomScale:newZoomScale animated:YES];
}

When I use NSLog messages within my doubleTapResponse, I can get responses from my console. However it does not do anything. What could be the problem?I am using iOS6.1

Sarp Kaya
  • 3,686
  • 21
  • 64
  • 103
  • Try [Click on][1] [1]: http://stackoverflow.com/questions/8891356/uiimageview-and-uiscrollview-zoomingi hope this will help you. – Bhavesh Nayi Aug 05 '13 at 06:59

2 Answers2

0
[doubleTapRecogniser addTarget:scrollView action:@selector(doubleTapResponse:)];

should be

[doubleTapRecogniser addTarget:self action:@selector(doubleTapResponse:)];

because the scrollview does not know what that method doubleTapResponse is. Currently it is throwing an exception because it is trying to call the target of the UISCrollView with your doubleTapResponse method, you must add the target of self, and implement this method yourself. In here goes the logic for zooming I presume.

You must also define: doubleTapResponse in your viewcontroller (or class that you are using)

see this for more info: Ray Wenderlich guide

In order to zoom please look at the following article: QUESTION

Community
  • 1
  • 1
Mitchell Currie
  • 2,769
  • 3
  • 20
  • 26
0

The error clearly says that the run time searched for a method named doubleTapResponse in the scrollview class you are using. Even if changing the target to self doesn't work, its the method definition place you have to change either the scrollview or the viewcontroller.

Satheesh
  • 10,998
  • 6
  • 50
  • 93