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
用適當的代碼更新你的問題(方法) –