2012-02-15 5 views
1

私はUILongPressGestureRecognizerを使用すると、2度目にしか動作しません... 3秒間ボタンを押しても動作しませんが、2度目は3秒押しますボタンは正常に動作します...いくつかのアイデア?UILongPressGestureRecognizerは、2度目の呼び出しのみです

-(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]; 
}} 

すべてのお友達に感謝します。

敬具

答えて

2

ので初めてでジェスチャーをあなたは...ユーザーのアクションにそれを追加しますので、のviewDidLoadで、たとえばその前にボタンにジェスチャーを追加するボタンに追加されていません。

関連する問題