2

这是我的问题,我想用多个按钮来做,我只用一个按钮来做......

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

}

4

1 回答 1

3

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

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

于 2012-02-02T11:13:29.823 回答