题
因此,我有一个带有Checkmark附件类型的桌面视图,我有这样的方法:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger newRow = [lastIndexPath row];
NSUInteger oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1;
if (newRow != oldRow) {
UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
newCell.accessoryType = UITableViewCellAccessoryCheckmark;
UITableViewCell *oldCell = [tableView cellForRowAtIndexPath:lastIndexPath];
oldCell.accessoryType = UITableViewCellAccessoryNone;
lastIndexPath = indexPath;
}
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
而且它似乎是第一次工作正常,但是当我第二次选择该行时,它将我扔掉并说Exc_Bad_Access。当我将模拟器切换为4.3时,它将选择仅行,然后不起作用。有人可以帮忙吗?
解决方案
利用 self.lastIndexPath = indexPath
如果您声明了@property lastIndexPAth
.
不隶属于 StackOverflow