0

I have read this question:

Relevant question

And i still don't really get how to use selectors with number of parameters.

Here is my code:

{
...
//add single tap gesture to the view
SEL mySelector = @selector(handleSingleTap:withScroll:);
UIGestureRecognizer* singleTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:mySelector];
[myView addGestureRecognizer:singleTap];
...
}

and:

- (void)handleSingleTap:(UITapGestureRecognizer *)recognizer withScroll:(UIScrollView*)scroll {
    ...
}

But of course it will not work. the (UIScrollView*)scroll is nil at run time.

How can i set it to be (UIScrollView*)scroll for instance?

Any help would be much appreciated.

Community
  • 1
  • 1
Itzik984
  • 15,968
  • 28
  • 69
  • 107
  • 2
    Read the overview section of the `UIGestureRecognizer` docs. The selector must be in exactly one of two specific forms. – rmaddy Jan 22 '14 at 00:20

2 Answers2

2

The selector of UIGestureRecognizer works only with 1 argument, the recognizer itself calls your selector with only 1 argument so any other arguments in the method will be nil since there are no more arguments in the calling stack.

Dima
  • 8,586
  • 4
  • 28
  • 57
0

What I do is sending a single parameter that is actually an NSDictionary ... so I can send lot of information in a single parameter. GL HF