简体   繁体   English

带按钮的UIScrollView。 触摸时高亮显示的按钮,仍然滚动滚动视图

[英]UIScrollView with Button. Button to Highlight when touched, and still scroll the scrollview

I have some UIButtons within a UIScrollView. 我在UIScrollView中有一些UIButton。 I want to highlight when touched, but still scroll if dragged. 我想在触摸时突出显示,但如果拖动仍然滚动。

I do not want to delay the button touches. 我不想延迟按钮的触摸。 However, as soon as the scroll view detects a drag/scroll, I want to cancel the UIButton touch and proceed with the scrolling of the UIScrollView. 但是,一旦滚动视图检测到拖动/滚动,我想取消UIButton触摸并继续滚动UIScrollView。

I have included the following... 我包括以下内容...

_scrollView.delaysContentTouches = NO;

...but (obviously) the button touch does not cancel when dragged. ...但是(显然)拖动时按钮的触摸不会取消。 Does anyone have any suggestions as to how I can implement this functionality? 是否有人对我如何实现此功能有任何建议?

This is very similar to the question asked here at: 这与此处的问题非常相似:

iOS UIScrollView cancel UIButton touch on scroll iOS UIScrollView取消滚动上的UIButton触摸

But I don't understand the answer as I'm a fairly new developer. 但是我不了解答案,因为我是一位相当新的开发人员。 more help on the answer would be much appreciated. 在答案上的更多帮助将不胜感激。

His answer means: 他的回答是:

You should create a subclass of UIScrollView, and override touchesShouldCancelInContentView. 您应该创建UIScrollView的子类,并覆盖touchesShouldCancelInContentView。

For each Button :"show highlight effect for UIControlEventTouchDown." 对于每个Button:“显示UIControlEventTouchDown的突出显示效果。” mean: 意思:

[button addTarget:self action:@selector(onTouchDownBtn:) forControlEvents:UIControlEventTouchDown];

Not sure the answer works as you want, I just explain the answer. 不确定答案是否如您所愿,我只解释答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM