我想创建一个用户可以选中的表,并使用复选标记取消选择:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *) indexPath
{
...;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
- (void)tableView:(UITableView *) tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
...;
newCell.accessoryType = UITableViewCellAccessoryCheckmark;
...;
}
Run Code Online (Sandbox Code Playgroud)
当我再次点击勾选标记的单元格时,我试图删除复选标记,但只需要点击2次而不是一次.
如果我将选择样式设置为默认值,当我单击所选行时,它会删除蓝色突出显示; 再次单击,它会删除复选标记.
我也尝试过一些条件语句didSelectRowAtIndexPath,但它们只响应第二次点击.
导致问题的原因是什么?如何解决?
我有一个UISegmentedControl加载其他UIViewController.回去时,我希望看到它未被选中.我尝试设置selectedSegmentIndex = -1并选择= NO,但它们不起作用.有什么建议?