在iPhone App中单击表格视图单元格我要显示表格视图单元格附件类型在didSelectRowAtIndexPath上的复选标记我正在编写代码
if(indexPath.row ==0)
{
[tableView cellForRowAtIndexPath:indexPath].accessoryType=UITableViewCellAccessoryCheckmark;
}
Run Code Online (Sandbox Code Playgroud)
并显示复选标记.
但在我的情况下,我想允许用户一次只检查单元格意味着如果用户选择其他行然后应该检查该行并且之前检查应该是未选中的
我怎样才能做到这一点?
我有一个UITableView27行的人口.我正在尝试更改accessoryType所选单元格.我在didSelectRowAtIndexPath:委托方法中这样做.
我面临的问题是,当选择一行并更改accessoryType单元格时,该行的第十一行也会被修改.
我已经尝试打印该[indexPath row]值,但它只显示选中的行而不是另一行.
我对这些东西感到很困惑; 请帮帮我.
添加代码 cellForRowAtIndexPath方法
UITableViewCell *cell;
if ([indexPath row] == 0) {
cell = [tableView dequeueReusableCellWithIdentifier:@"acell"];
}
else {
cell = [tableView dequeueReusableCellWithIdentifier:@"bcell"];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (cell == nil && [indexPath row] != 0) {
cell = [[[UITableViewCell alloc] initWithStyle:
UITableViewCellStyleSubtitle reuseIdentifier:@"bcell"] autorelease];
}
else if(cell == nil && [indexPath row] == 0){
cell = [[[UITableViewCell alloc] initWithStyle:
UITableViewCellStyleSubtitle reuseIdentifier:@"acell"] autorelease];
}
if …Run Code Online (Sandbox Code Playgroud)