TableView 或者collectionView 获取点击的cell 和当前行数的方法

来源:互联网 发布:网络射像头 编辑:程序博客网 时间:2024/05/21 08:04

1.第一种方法

- (void)btnActionForUserSetting:(id) sender {

 

 NSIndexPath *indexPath = [self.tableViewindexPathForSelectedRow];

 UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];

}

2.第二种方法

- (void)deleteCellWithButton:(UIButton *)button {


    //1.获取到删除的行数

    HDAddDiagnosisTableViewCell *cell = (HDAddDiagnosisTableViewCell *)button.superview.superview;

    NSIndexPath *indexPath = [self.tableViewindexPathForCell:cell];

    NSLog(@"delete:%ld",(long)indexPath.row);


    //2.执行删除操作

}


0 0
原创粉丝点击