[英]imageView tapGesture vs button touchUpInside , with didSelectRowAtIndexPath
When I use inside a TableViewCell
an UIImageView
and tapGesture
.当我在
TableViewCell
使用UIImageView
和tapGesture
。 If I tap directly on the image it trigger:如果我直接点击它触发的图像:
didSelectRowAtIndexPath
my_image_tap_deletage
If I used a UIButton
with UIControlEventTouchUpInside
inside a TableViewCell
if I tap directly on the button it trigger:如果我在
TableViewCell
内使用带有UIControlEventTouchUpInside
的UIButton
如果我直接点击它触发的按钮:
my_button_tap_delegate
I know I can use UIButton
with image on it, instead of UIImageView
, but still.我知道我可以使用带有图像的
UIButton
代替UIImageView
,但仍然可以。
Questions:问题:
1.Why there is such different in the event triggering? 1.为什么事件触发会有这么大的不同?
2.How can i make the image act like the button, to trigger only the control event without didSelectRowAtIndexPath
. 2.如何使图像像按钮一样,只触发没有
didSelectRowAtIndexPath
的控制事件。
UPDATE: I don't know if it's important, but i just want to notice that I'm creating the UITableViewCell from xib + subclass.更新:我不知道它是否重要,但我只想注意我正在从 xib + 子类创建 UITableViewCell。
UPDATE 2: Well, half of blame on me.更新2:嗯,一半怪我。 I forget to mention one more thing.
我忘了再提一件事。 I set the gesture to gesture.numberOfTapsRequiered=2;
我将手势设置为gesture.numberOfTapsRequiered=2;
If it's 1, the didSelectRowAtIndexPath is not called, and it's OK如果为1则不调用didSelectRowAtIndexPath,就OK了
If it's 2, the didSelectRowAtIndexPath is called.如果为 2,则调用 didSelectRowAtIndexPath。 i tried with gesture.cancelsTouchesInView=YES/NO (both..) and the didSelec still called.
我尝试使用gesture.cancelsTouchesInView=YES/NO(两者都......)并且didSelec仍然被调用。
Maybe with 2 taps, the SDK decide that the didSelect will be called no matter what?也许用 2 个水龙头,SDK 决定无论如何都会调用 didSelect?
Hope I'm clear here.希望我在这里很清楚。 Thanks in advance.
提前致谢。
As for as I've noticed, if you've done every thing correct to add the image view to the table view cell and if you tap on the UIImageView
, it should only call the imageView's action, not the table view's didSelectRowAtIndexPath: delegate method.正如我所注意到的,如果您已经正确地将图像视图添加到表格视图单元格,并且如果您点击
UIImageView
,它应该只调用 imageView 的操作,而不是表格视图的didSelectRowAtIndexPath:委托方法.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.