您的位置:首页 > 产品设计 > UI/UE

UITableView中cell上按钮获取所选cell

2016-07-20 15:03 471 查看
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];
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: