简体   繁体   English

imageView tapGesture 与按钮 touchUpInside,使用 didSelectRowAtIndexPath

[英]imageView tapGesture vs button touchUpInside , with didSelectRowAtIndexPath

When I use inside a TableViewCell an UIImageView and tapGesture .当我在TableViewCell使用UIImageViewtapGesture 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内使用带有UIControlEventTouchUpInsideUIButton如果我直接点击它触发的按钮:

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.

相关问题 如何在UIView中添加TouchUpInside按钮 - How to add TouchUpInside for button in UIView 是否在视图上自动完成按钮touchupinside操作? - Button touchupinside action done automatically on view appear? UITableCell按钮touchUpInside单击了单元格索引按钮 - UITableCell button touchUpInside with index of cell whos button was clicked 如何检索按钮上的TouchUpInside返回(MonoTouch)? - How do I retrieve the TouchUpInside return on a button (MonoTouch)? 如何在按钮和 TouchUpInside 上使用两种不同的 SWIPE 方法? - How to have two different methods for a SWIPE over a button and a TouchUpInside? 当处于子视图时,我无法将按钮的 touchUpInside 调用到 ViewController - I can't call touchUpInside of button to ViewController when is at a subview 通过按钮选择一行…使用didSelectRowAtIndexPath - selecting a row by means of a button … using didSelectRowAtIndexPath 带有[self.view removeFromSuperview]的touchUpInside Back按钮时,上一个视图无响应 - Previous view unresponsive when touchUpInside Back button with [self.view removeFromSuperview] 将字符串从DidSelectRowAtIndexPath传递给按钮单击操作 - Pass a string from DidSelectRowAtIndexPath to a button-click action Touches开始覆盖touchUpInside操作 - TouchesBegan overriding touchUpInside actions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM