使用Core Data BOOL检查单元格

时间:2013-02-07 02:57:56

标签: ios xcode core-data ios6 boolean

升级到IOS 6.1后,已检查的单元功能已不再... 单击一个单元格时,日志显示记录更新,但单元格上的物理复选标记未更新。在第二次单击时,将显示复选标记。反之亦然,需要两个选项来删除复选标记。我很难过,这在6.0及更早版本中完美无缺。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// find the cell being touched and update its checked/unchecked image
CheckedCell *targetCustomCell = (CheckedCell *)[tableView cellForRowAtIndexPath:indexPath];
[targetCustomCell checkAction:nil];

// don't keep the table selection
[tableView deselectRowAtIndexPath:indexPath animated:YES];

Athlete *checkedAthlete = (Athlete *)[self.fetchedResultsController objectAtIndexPath:indexPath];
[checkedAthlete setValue:[NSNumber numberWithBool:targetCustomCell.checked] forKey:@"athleteChecked"];
NSLog(@"%@",checkedAthlete);

如果checkAthlete setValue行已注释掉,则检查单元格是否正常。我怎样才能解决这个问题?提前谢谢!

- (void)checkAction:(id)sender
{
self.checked = !self.checked;
UIImage *checkImage = (self.checked) ? [UIImage imageNamed:@"checked.png"] : [UIImage imageNamed:@"unchecked.png"];
[checkButton setBackgroundImage:checkImage forState:UIControlStateNormal];

}

0 个答案:

没有答案