Seleccione un botón mucho og con UILongPressGestureRecognizer

This is my problem, i want do it in multiple buttons and i only do it with one button...

-(void)viewDidLoad
{
UILongPressGestureRecognizer *longpressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressHandler:)];
longpressGesture.minimumPressDuration = 3;
[longpressGesture setDelegate:self];

[self.pieza11 addGestureRecognizer:longpressGesture];
[self.pieza12 addGestureRecognizer:longpressGesture];
[self.pieza13 addGestureRecognizer:longpressGesture];
[self.pieza14 addGestureRecognizer:longpressGesture];

    [longpressGesture release];

}

preguntado el 02 de febrero de 12 a las 11:02

1 Respuestas

one gesture works for one object only. so in your case it might be working with the last one pieza14.

if you want this for all then you have to add separate UILongPressGestureRecognizer to all buttons.

Respondido 02 Feb 12, 15:02

Some example please? im doing it: - Alberto Juárez

-(IBAction)tocarLargo :(id)sender { UILongPressGestureRecognizer *longpressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressHandler:)]; longpressGesture.minimumPressDuration = 3; [longpressGesture setDelegate:self]; [self.pieza11 addGestureRecognizer:longpressGesture]; } It is correct? - Alberto Juárez

dear on a button event you are adding a longPress gesture to another button. what really you want to do please explain it in details step by step. - Prashant Bhayani

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.