您的位置:首页 > 其它

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

2016-08-11 09:17 1366 查看
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.tableView
indexPathForCell:cell];

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

    //2.执行删除操作

}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐