UILongPressGestureRecognizer只调用第二次

问题描述:

这是我的问题,当我使用UILongPressGestureRecognizer,它只在第二次工作...我按了3秒的按钮,它不工作,但第二次,我推3秒按钮它工作正常...有些想法?UILongPressGestureRecognizer只调用第二次

-(IBAction)seleccionar1:(id)sender{ 
UILongPressGestureRecognizer *longpressGesture =[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressHandler:)]; 
longpressGesture.minimumPressDuration = 3; 
[longpressGesture setDelegate:self]; 
[sender addGestureRecognizer:longpressGesture];} 

-(IBAction)seleccionar2:(id)sender{ 
UILongPressGestureRecognizer *longpressGesture =[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressHandler:)]; 
longpressGesture.minimumPressDuration = 3; 
[longpressGesture setDelegate:self]; 
[sender addGestureRecognizer:longpressGesture];} 

- (void)longPressHandler:(UILongPressGestureRecognizer *)gestureRecognizer{ 
if(gestureRecognizer.view==boton1) 
{ 
    [boton1 setTitle:@"Funciona 1" forState:UIControlStateNormal]; 
} 
if(gestureRecognizer.view==boton2) 
{ 
    [boton2 setTitle:@"Funciona 2" forState:UIControlStateNormal]; 
}} 

感谢所有的朋友。

问候

,因为在第一次的动作不是添加到按钮添加它的用户动作..手势之前例如在viewDidLoad中添加这样的按钮。