在UITableView中,改变cell的alpha 值,在向下拉重用时在visiableCells中alpha 值没有改变
这是cellForRowAtIndexPath函数里最底下的测试代码,输出此时的cell的地址和alpha值,以及此时visiableCells中所有cell的地址和alpha值:
printf("第%d个cell:<%p>\t alpha:%f\n",no++,cell,cell.alpha);
printf("visiableCells里有%ld个元素\n",self.tableView.visibleCells.count);
for (XYTableCell* cell in self.tableView.visibleCells) {
printf("%p\t",cell);
printf("这个cell的alpha值为:%f\n",cell.alpha);
}
return cell;
运行之后得到的结果是:
第10个cell:<0x7f858b65c7e0> alpha:0.500000
//第十个cell在return前alpha值是0.5
visiableCells里有8个元素
0x7f858b51af60 这个cell的alpha值为:0.500000
0x7f858b528990 这个cell的alpha值为:1.000000
0x7f858b52f0f0 这个cell的alpha值为:0.500000
0x7f858b535320 这个cell的alpha值为:0.500000
0x7f858b53bf40 这个cell的alpha值为:0.500000
0x7f858b695500 这个cell的alpha值为:1.000000
0x7f858b729c00 这个cell的alpha值为:1.000000
0x7f858b4afa40 这个cell的alpha值为:1.000000
第11个cell: alpha:0.500000
visiableCells里有8个元素
0x7f858b528990 这个cell的alpha值为:1.000000
0x7f858b52f0f0 这个cell的alpha值为:0.500000
0x7f858b535320 这个cell的alpha值为:0.500000
0x7f858b53bf40 这个cell的alpha值为:0.500000
0x7f858b695500 这个cell的alpha值为:1.000000
0x7f858b729c00 这个cell的alpha值为:1.000000
0x7f858b4afa40 这个cell的alpha值为:1.000000
//然而返回之后就变成1.0了,这是为什么?
0x7f858b65c7e0 这个cell的alpha值为:1.000000