被 cell 复用折磨惨了, iOS 大牛帮我看看怎么回事啊
http://pan.baidu.com/s/1mhNwNf6
http://pan.baidu.com/s/1mhNwNf6
|
dctyApr 20, 2016
1
下了代码看了一下,想不明白现在的人为什么要这么写.
|
|
jayzjj000Apr 20, 2016
3
竟然还要手动去下代码。。。懒癌犯了不想下怎么办
|
|
anerevolApr 20, 2016
4
看了下,里面的代码是没有问题的啊,是被你改出来的问题?
|
|
a412739861Apr 20, 2016
5
@jayzjj000 是啊,放 github 上多方便……
|
|
rulerstormApr 20, 2016
6
这样问问题都有人理。。。 V 友真是耐心善良,赞
|
|
anerevolApr 20, 2016
7
MainTableViewCell 里面,注释掉[self showOrderNumbers:self.number];
- (IBAction)addButton:(id)sender { self.number =[self.goodsNumber.text intValue]; self.number +=1; self.plusBlock(self.number,YES); // [self showOrderNumbers:self.number]; } MainViewController 里面,-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 函数里面添加一行,大概在 139 行后 bself.shoppcartview.OrderList.objects = self.ordersArray; [bself.shoppcartview updateFrame:self.shoppcartview.OrderList]; [bself.shoppcartview.OrderList.tableView reloadData]; // 添加下面这行 [bself.maintable reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; 然后你再想想你怎么改的代码,如果还不能明白的话,那我就爱莫能助了。 |
|
XVXVXXXApr 20, 2016
8
我跑了下 Demo ,好像没你那个 GIF 里面的复用问题? =。= 另外代码还是放 github 上吧
|
|
9
@XVXVXXX
@a412739861 @anerevol @dcty @rulerstorm 不知道什么原因 github 一直上传不了 只能用 osChina 了 https://git.oschina.net/gugogo/shopCart.git |
|
10
|
|
11
|
|
lxian2Apr 20, 2016
12
什么问题啊,运行挺正常的额
|
|
DSKcppApr 20, 2016
14
把商品数量写到 model 里
你现在等于没有保存 |
|
lxian2Apr 20, 2016
15
你用的 _dataArray 给 cell 当作 model, 可是在 cell.plusBlock 里面根本没有 update 这个 array
而且这个 OrderModel *model = [[OrderModel alloc]initWithDictionary:[item[@"goods"] objectAtIndex:indexPath.row]]; 这个 _dataArray 里面根本就没有 orderCount |
|
lxian2Apr 20, 2016
16
感觉你是吧东西弄混了 你的_dataArray 看起来是用来初始化 model 的(初始化商品信息),后面你就不应该用这个 _dataArray 了
|