gpt4 book ai didi

iphone - 触摸 UITableViewCell 中的 UIButton 无法滚动表格

转载 作者:行者123 更新时间:2023-12-03 19:01:10 25 4
gpt4 key购买 nike

我需要在 UITableViewCell 中有一个 UIButton,一切正常,除了当我触摸按钮内部并移动手指时,表格不会滚动。

我尝试子类化UIButton并在touchesMoved:方法中将相同的消息发送到self.nextResponder,或者调用touchesCancelled并希望它将触摸事件传递给下一个响应者,它们都不起作用。

有什么好的办法可以解决这个问题吗?目前我正在 UITableViewCell 顶部添加一个 UIView ,并手动检测触摸事件,分别将结果传递给按​​钮或单元格的其余部分,但这有点有点脏。

最佳答案

您可以尝试设置 delaysContentTouches UITableView 的属性至 YES

此外,您还可以设置 canCancelContentTouches YES

If the value of this property is NO, the scroll view does not scroll regardless of finger movement once the content view starts tracking.

来源:UIScrollView Class Reference

尝试:

_yourTableView.delaysContentTouches = YES;
_yourTableView.canCancelContentTouches = YES;

关于iphone - 触摸 UITableViewCell 中的 UIButton 无法滚动表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8379206/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com