我从代码创建了100个按钮。现在我想对长按钮进行响应。 对于每个按钮我叫enxt代码:
UILongPressGestureRecognizer *longPressGesture = [[[UILongPressGestureRecognizer alloc]
initWithTarget:self
action:@selector(longPress:)]
autorelease];
[longPressGesture setMinimumPressDuration:1];
[button addGestureRecognizer:longPressGesture];
[self.view addSubview:button];
但longPress
方法不叫。
有人知道为什么吗?
的':'在选择想'longPress'需要的参数。是这样吗?如果没有,请尝试构建正确的选择器,不要使用':'。当然,“自我”也必须对此作出回应。 – 2012-02-22 09:37:36
这是我的方法的签名: - (void)longPress:(UILongPressGestureRecognizer *)手势。它适用于我添加recognaizer到我的视图,而不是按钮。但我需要使用自己在代码中创建的按钮。 – Radislav 2012-02-22 09:41:41