我正在尝试切换配件类型当选择/取消选择表格单元格时...行为应该是:点击 -> 将accessoryType 设置为UITableViewCellAccessory复选标记-> 再次点击单元格 -> 回滚到UITableViewCell 附件骨骼类型。
我的控制器中的实现如下:
- (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];
}
...无论如何,一旦样式配置为UITableViewCellAccessory复选标记我无法将其恢复到UITableViewCell 附件骨骼!
我也尝试打电话:
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
但没有删除复选标记...我该怎么办?
编辑:实现没问题,问题出在自定义 UITableViewCell 子类中......抱歉:P
如果这是你想要的,试试这个
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if (cell.accessoryType == UITableViewCellAccessoryCheckmark)
{
cell.accessoryType = UITableViewCellAccessoryNone;
}
else
{
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)