2012-02-02 50 views
2

选择很多OG按钮这是我的问题,我想这样做在多个按钮,我只用一个按钮做...与UILongPressGestureRecognizer

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

}

回答

3

一个手势适用于一个只有对象。 所以在你的情况下,它可能与最后一个pieza14一起工作。

如果你想要这一切,那么你必须添加单独的UILongPressGestureRecognizer到所有按钮。

+0

请举例子?即时通讯做它: – 2012-02-02 13:38:41

+0

- (IBAction为)tocarLargo:(ID)发送方 { UILongPressGestureRecognizer * longpressGesture = [[UILongPressGestureRecognizer的alloc] initWithTarget:自动作:@selector(longPressHandler :)]; longpressGesture.minimumPressDuration = 3; [longpressGesture setDelegate:self]; [self.pieza11 addGestureRecognizer:longpressGesture]; } 这是正确的? – 2012-02-02 13:41:02

+0

亲爱的一个按钮事件,你正在添加一个长按手势到另一个按钮。 你真正想做什么,请详细解释一步一步。 – Prashant 2012-02-03 05:03:49

相关问题