【发布时间】:2013-06-08 19:18:06
【问题描述】:
我是 xcode 的新手,我正在使用此代码从我的表中最多选择 10 行。此代码正在运行,但它存在一个问题,假设当我从中选择一行时,我的选择会自动选择其他一些值。我不明白这是什么错误,请帮我删除这个错误。谢谢
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
if ([selectedCell accessoryType] == UITableViewCellAccessoryNone) {
if(count < 10)
{
[selectedCell setAccessoryType:UITableViewCellAccessoryCheckmark];
[selectedobjects addObject:[NSNumber numberWithInt:indexPath.row]];
count++;
}
} else {
[selectedCell setAccessoryType:UITableViewCellAccessoryNone];
[selectedobjects removeObject:[NSNumber numberWithInt:indexPath.row]];
count --;
}
}
【问题讨论】:
标签: ios uitableview row selection