相关疑难解决方法(0)

UITableView一次只能选中一行

你认为这很容易.使用此代码,我可以检查表中的多行,但我想要的是一次只检查一行.如果用户选择不同的行,那么我希望旧行只是自动取消选中.不知道该怎么做.这是我的代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

[tableView deselectRowAtIndexPath:indexPath animated:YES];


UITableViewCell *theCell = [tableView cellForRowAtIndexPath:indexPath];

if (theCell.accessoryType == UITableViewCellAccessoryNone) {
    theCell.accessoryType = UITableViewCellAccessoryCheckmark;
    }

    else if (theCell.accessoryType == UITableViewCellAccessoryCheckmark) {
    theCell.accessoryType = UITableViewCellAccessoryNone;
    }
}
Run Code Online (Sandbox Code Playgroud)

感谢您提供的任何帮助!

xcode ios4 ios xcode4 ios5

18
推荐指数
6
解决办法
5万
查看次数

标签 统计

ios ×1

ios4 ×1

ios5 ×1

xcode ×1

xcode4 ×1