美文网首页别人的iOS精华iOS小功能点iOS Developer
如何通过点击UITableViewCell中的控件找到所在cel

如何通过点击UITableViewCell中的控件找到所在cel

作者: linbj | 来源:发表于2016-10-28 11:51 被阅读112次

当一个UITableView有很多个Cell,每个Cell拥有若干按钮。

点击UITableViewCell中的控件之后,如何找到自己属于哪个indexPath?

方法一
int floor =[_tableView
indexPathForCell:((exampleCell
*)[[sender   superview]superview])].row;
方法二
CGRect rc = [btn.superview btn.frame toView:_tableView];
NSIndexPath *indexPath = [_tableView indexPathForRowAtPoint:CGPointMake(rc.origin.x+rc.size.width/2, rc.origin.y+rc.size.height/2)];
        ;//CGPointMake内的参数是点击当前控件处于cell中位置

相关文章

网友评论

    本文标题:如何通过点击UITableViewCell中的控件找到所在cel

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