PostCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PostCell"];
if (cell == nil) {
cell = [[PostCell alloc]initWithFrame:rect_detail];
}
cell.btn_select.tag = indexPath.row + 5000;
[cell.btn_select addTarget:self action:@selector(selectYouhuiquan:) forControlEvents:UIControlEventTouchUpInside];
//选中、未选中状态
[cell.btn_select setImage:[UIImage imageNamed:@"购物车-未选中"] forState:UIControlStateNormal];
[cell.btn_select setImage:[UIImage imageNamed:@"购物车-勾选"] forState:UIControlStateSelected];
- (void)selectYouhuiquan:(UIButton *)button
{
NSInteger index = button.tag - 5000;
// PostCell *cell_select = (PostCell *)[button superview];
// [cell_select.btn_select setImage:[UIImage imageNamed:@"购物车-勾选"] forState:UIControlStateNormal];
lastButton.selected = NO;
button.selected = YES ;
lastButton = button ;
// NSIndexPath *indexPath=[NSIndexPath indexPathForRow:index inSection:2];
// PostCell *cell = [v_post.table_post cellForRowAtIndexPath:indexPath];
// [cell.btn_select setImage:[UIImage imageNamed:@"购物车-未选中"] forState:UIControlStateNormal];
}
UITableView中cell上按钮获取所选cell
最新推荐文章于 2022-09-01 21:50:20 发布