【发布时间】:2015-05-26 01:44:51
【问题描述】:
我有一个 UITableView。有 5 行,每行有 4 个按钮。当用户点击按钮时,我想检索行 ID。
我使用UITapGestureRecognizer 来识别被选中的按钮。现在我想找到按钮所在的行。
我想使用 cell.myButton.tag =indexRow.row;。但是,我无法从ImageTapped 方法接收它。有人可以帮我吗 ?
以下代码是cellForRowAtIndexPath 的一部分
cellForRowAtIndexPath
UITapGestureRecognizer *tap = nil;
tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(ImageTapped:)];
[cell.myButton addGestureRecognizer:tap];
...对于另一个按钮也是如此。
ImageTapped方法
- (void) ImageTapped:(UITapGestureRecognizer *) recognizer {
if(recognizer.state == UIGestureRecognizerStateEnded)
{
}
}
【问题讨论】:
-
@iphonic : TapGesture 不适用于 UIButtons,谁告诉你的?
-
@iphonic : 我尝试并使用 TapGesture 来查找 UIButton 上的双击。 example
-
@FahimParkar Applogies 先生,它确实有效,我有不同的想法,感谢您的澄清..
标签: ios objective-c