我正在创建一个函数来跟踪截止日期。当您在截止日期表格视图中选择一行时,我将accessoryType更改为复选标记。这与此代码工作完美:当你选择了一个表格单元格和滚动因此它dissappears,当它再次出现accessoryType再次发生无当UITableViewCell被隐藏时,accessoryTypeCheckmark消失
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
Cell *selectedCell = (Cell *)[tableView cellForRowAtIndexPath: indexPath];
if (selectedCell.accessoryType == UITableViewCellAccessoryNone) {
[Deadline setDone: TRUE onIndex:indexPath.row];
selectedCell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
[Deadline setDone: FALSE onIndex:indexPath.row];
selectedCell.accessoryType = UITableViewCellAccessoryNone;
}
[tableView deselectRowAtIndexPath:indexPath animated: YES];
}
的问题。
我在的cellForRowAtIndexPath决定accessoryType代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CellIdentifier";
Deadline *d = [self.arrDeadlines objectAtIndex:indexPath.row];
Cell *currCell = (Cell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (currCell == nil)
{
UIViewController *c = [[UIViewController alloc] initWithNibName:@"Cell" bundle:nil];
currCell = (Cell *)c.view;
[c release];
}
currCell.lblTitle.text = d.name;
currCell.accessoryType = d.done == TRUE ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
return currCell;
}
如何解决这个问题?
1)回滚完成后,deadline.done返回的值是多少? 2)显示更多'cellForRowAtIndexPath'的代码。你如何管理细胞的出球? – kpower 2011-03-16 10:27:18
1)即使我选择单元格然后取消选择单元格,它总是一样的,因为我无法运行[tableView reloadData]。 2)源代码更新如上! – 2011-03-16 11:35:38