【问题标题】:Select a lot og button with UILongPressGestureRecognizer使用 UILongPressGestureRecognizer 选择很多按钮
【发布时间】:2012-02-02 11:08:14
【问题描述】:

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

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

}

【问题讨论】:

    标签: iphone uipangesturerecognizer


    【解决方案1】:

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

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

    【讨论】:

    • 请举个例子?我正在做:
    • -(IBAction)tocarLargo :(id)sender { UILongPressGestureRecognizer *longpressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressHandler:)]; longpressGesture.minimumPressDuration = 3; [longpressGesture setDelegate:self]; [self.pieza11 addGestureRecognizer:longpressGesture]; } 正确吗?
    • 亲爱的按钮事件,您正在向另一个按钮添加长按手势。你真正想做什么请一步一步详细解释。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-24
    • 1970-01-01
    • 2011-03-12
    • 1970-01-01
    相关资源
    最近更新 更多