在我的项目中,我在TableView中有5行,每个单元格有四个按钮,我有20个按钮,我的要求是我想为每个按钮设置标记值,如
in First Cell -- 1 for btn1, 2 for btn2, 3 for btn3, 4 for btn4
Second Cell-- 5 for btn5, 6 for btn6, 7 for btn7, 8 for btn8
像所有五个细胞一样,我需要像这样设置标签值
注意:当我滚动TableView时,它不会更改标记值
我在cellForRowAtIndexPath委托方法
中设置了这样的标记值UIButton *btnLeftW,*btnLeft,*btnRight,*btnRightW;
btnLeftW=(UIButton*)[cell viewWithTag:90];
btnLeft=(UIButton*)[cell viewWithTag:91];
btnRight=(UIButton*)[cell viewWithTag:92];
btnRightW=(UIButton*)[cell viewWithTag:93];
btnLeftW.tag=indexPath.row;
btnLeft.tag=indexPath.row;
btnRight.tag=indexPath.row;
btnRightW.tag=indexPath.row;
仅提供
0,0,0,0
1,1,1,1
2,2,2,2
3,3,3,3
4,4,4,4
答案 0 :(得分:2)
试试这个
btnLeftW.tag = indexPath.row*4 + 1;
btnLeft.tag = indexPath.row*4 + 2;
btnRight.tag = indexPath.row*4 + 3;
btnRightW.tag = indexPath.row*4 + 4;