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