0
我是新的Objective-C和iOS开发人员,我有一个奇怪的问题,只在一个特定的情况。这是我的开关部分代码:如何获取TableView的第一个单元格?
if(nowSolo>-1){
[soloarray replaceObjectAtIndex:nowSolo withObject:[NSNumber numberWithBool:NO]];
NSIndexPath *indexPath2 = [NSIndexPath indexPathForRow:nowSolo inSection:0];
CustomCell *cell2=[_tableView cellForRowAtIndexPath:nowSolo];
cell2.solo.backgroundColor=[UIColor colorWithRed:0.29 green:0.67 blue:0.62 alpha:1.0];
}
nowSolo=row;
[soloarray replaceObjectAtIndex:row withObject:[NSNumber numberWithBool:YES]];
cell.solo.backgroundColor=[UIColor colorWithRed:0.13 green:0.41 blue:0.37 alpha:1.0];
一切顺利,但是当可变nowSolo等于0,则cell2 = null
。我不明白为什么,因为像1,2,3等其他值它工作正常。
当你想要得到的细胞 ? – vaibhav
如果条件之外使用'cell'。它是什么 ? – Mahesh
用适当的代码更新你的问题(方法) –