美文网首页
iOS 点击tableView 区头(组头)上的控件,获取点击的

iOS 点击tableView 区头(组头)上的控件,获取点击的

作者: 三千沉浮 | 来源:发表于2019-04-11 11:33 被阅读0次

最近开发项目遇到一个需要点击区头上的按钮拿到该区头是哪个区,查找资料之后找到解决办法,上代码:

//获取触摸点的集合,可以判断多点触摸事件
    NSSet *touches=[event allTouches];
    //两句话是保存触摸起点位置
    UITouch *touch=[touches anyObject];
    CGPoint cureentTouchPosition=[touch locationInView:self.tableView];
    //得到cell中的IndexPath
    NSIndexPath *indexPath=[self.tableView indexPathForRowAtPoint:cureentTouchPosition];

上面这个方法可以获取任意点击位置的tableView的indexPath!

喜欢的小伙伴点个赞再走啊~

相关文章

网友评论

      本文标题:iOS 点击tableView 区头(组头)上的控件,获取点击的

      本文链接:https://www.haomeiwen.com/subject/ilxtwqtx.html