【发布时间】:2012-01-15 14:46:20
【问题描述】:
我正在尝试在选择/取消选择表格单元格时切换 accesoryType...行为应该是:点击 -> 将附件类型设置为 UITableViewCellAccessoryCheckmark -> 点击再次单元格 -> 回滚到 UITableViewCellAccessoryNone 类型。 我的控制器中的实现如下:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
}
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
[cell setAccessoryType:UITableViewCellAccessoryNone];
}
...无论如何,一旦将样式配置为 UITableViewCellAccessoryCheckmark,我将无法将其恢复为 UITableViewCellAccessoryNone! 我也试过打电话:
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
但不删除复选标记...我该怎么办?
编辑:实现没问题,问题出在自定义 UITableViewCell 子类中......对不起:P
【问题讨论】:
标签: ios uitableview