I have 2 buttons with “UILongPressGestureRecognizer”, to do it, i do:
Fot button 1:
-(IBAction)seleccionar46:(id)sender{
UILongPressGestureRecognizer *longpressGesture =[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressHandler:)];
longpressGesture.minimumPressDuration = 3;
[longpressGesture setDelegate:self];
[self.button1 addGestureRecognizer:longpressGesture];}
For button 2:
-(IBAction)seleccionar46:(id)sender{
UILongPressGestureRecognizer *longpressGesture =[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressHandler:)];
longpressGesture.minimumPressDuration = 3;
[longpressGesture setDelegate:self];
[self.button2 addGestureRecognizer:longpressGesture];}
And in “longpressGesture” i need differentiate between button1 and button2, but i can´t do it…
- (void)longPressHandler:(UILongPressGestureRecognizer *)gestureRecognizer{//Here i need do the differentation}
Thanks for all!
Best regards.
What you can do is use the
viewproperty ofUIGestureRecognizer, so if you save a reference to both your buttons, you can check for equality.So if you have
then you add the recognizers to the buttons you can do in the handler
hope it helps