【发布时间】:2015-12-17 07:41:08
【问题描述】:
我有一个 UIViewController 和一个 UITableView 和一个覆盖视图。在didSelectRowAtIndexPath 中显示了视图,但我希望它在用户放开屏幕后立即隐藏。因此,仅当用户按下单元格时才会显示视图,并在他松开时立即隐藏。
我尝试使用touchesEnded,但无法正常工作。
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
self.colorView.hidden = false
self.colorView.backgroundColor = colors[indexPath.row]
}
有什么建议吗?
【问题讨论】:
-
隐藏你对 touchesEnd 方法的看法 -(void)touchesEnded:(NSSet
*)touches withEvent:(UIEvent *)event -
您是否尝试向单元格添加手势识别器?
-
@CongTran 谢谢你的提示,我试过了,但是当我选择一个表格视图单元格时似乎没有调用 touchesbegan
-
您是否使用了自定义的 TableviewCell?如果是,您可以在 tableviewcell 上调用此方法,然后将此事件发送到您的 viewcontroller。
-
@CongTran 不,我没有,但我知道如何制作自定义单元格等。但是如何将事件发送到 vc?
标签: ios swift uitableview cocoa-touch