利用Tag值获取所在行的数组下标。购物车中的移除功能,
1、给按钮加TAG值,900起加上section(因为本UITableView是分组的,所以用section,如果是平铺的就用row)
cell.clearButton.tag=900+indexPath.section;
2、在按钮的点击事件中获取所属数组下标Btn.tag-900,作为参数调用CancelCartGoods
-(void)ToMove:(UIButton *)Btn{
ShopingCartCell *superView = (ShopingCartCell *)Btn.superview.superview;
GoodsID=superView.goods_id;
[self CancelCartGoods:Btn.tag-900];
}
3、
移除接口调用成功后,要移除数组中的下标所对应的那行数据,section即Btn.tag-900,_cartArray为全局可变数组,存储购物车中的商品列表
[_cartArray removeObjectAtIndex:section];