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

标签 iphone uitableview uibutton

我需要在 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/

相关文章:

iphone - 重新登录时 Facebook iOS Api 调用失败,但 isSessionValid 为 YES

iphone - 核心数据 - 存储图像 (iPhone)

iphone - 使用 eventkit 发送日历事件/邀请

ios - 其中一些带有 UIImageView 的 UITableViewCell

ios - 在iOS应用程序中的UIButtons上全局设置圆角

iphone - 带有图像的自定义 UIButton

iphone - Xcode 退出代码和信号

ios - 从 firebase 读取数据并填充 TableViewCell

ios - 从 UITableViewCell 隐藏删除按钮

ios - 真的很接近 NSAttributedString 吗?