目前我有一个 uitableview 用户可以滚动并选择一个单元格。选择单元格后,我保存该 indexpath 值,当用户返回到其中包含 uitableview 的视图时,我将该 indexpath 值传回并在 tableView:cellForRowAtIndexPath: 内为该单元格添加一个刻度:使用下面的代码。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//...
//Replaces previously selected cells accessory view (tick)
if (indexPath == oldCheckedData)
{
cell.accessoryType = UITableViewCellAccessoryCheckmark;
NSLog(@" Tick");
}
else
{
cell.accessoryType = UITableViewCellAccessoryNone;
NSLog(@"No Tick");
}
}
奇怪的是,在模拟器上测试它时它工作得很好......但是当我尝试在手机上测试它时,它永远不会进入第一个 if 语句......所以永远不会添加刻度。