简体   繁体   English

即使按下按钮子视图,如何使滚动视图滚动

[英]How To Make Scroll View Scroll Even If A Button Subview Is Pressed

There are countless questions about UIScrollView s, touch events and subviews, but I couldn't find one that solved my dilemma. 关于UIScrollView ,触摸事件和子视图,存在无数问题,但是我找不到能解决我的困境的问题。 I have a UIScrollView with delayed and cancellable content touches in which I have added UIButton s. 我有一个UIScrollView具有延迟的和可取消的内容触摸,在其中添加了UIButton I can scroll the view wherever I touch (including the buttons), but if my finger lingers on a button for too long, it registers as touching the button, as I want and is expected. 我可以在我触摸的任何位置(包括按钮)滚动视图,但是如果我的手指在按钮上停留的时间过长,它会根据我的期望和预期注册为触摸按钮。 However, if I then move my finger as if trying to scroll, the scroll view does not scroll - how can I make it do so? 但是,如果我然后像尝试滚动一样移动手指,则滚动视图不会滚动-如何使它滚动? The basic effect I am trying to achieve is like a UITableView handles touches for the cells. 我试图实现的基本效果就像UITableView处理单元格的触摸。

Thanks for your help. 谢谢你的帮助。

Try implementing the following in your UIScrollView subclass: 尝试在UIScrollView子类中实现以下内容:

- (BOOL)touchesShouldCancelInContentView:(UIView *)view {   
    return YES;
}

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

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