使用 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];
}
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];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种手势仅适用于一个对象。
所以在你的情况下,它可能与最后一个pieza14一起使用。
如果您想要所有按钮都这样做,那么您必须向所有按钮添加单独的 UILongPressGestureRecognizer。
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.