相关疑难解决方法(0)

如何使用UITableViewCellAccessoryCheckmark取消选中所有行

我有一个UITableView包含复选框的每一行使用UITableViewCellAccessoryCheckmark.我无法弄清楚如何使用该didSelectRowAtIndexPath方法取消选中所有复选框.

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

    UITableViewCell *oldCell;

    int count = [self.myTableRowNamesArray count];

    for (NSUInteger i = 0; i < count; ++i) {                                
        // Uncheck all checkboxes
        // OF COURSE THIS DOESN'T WORK
        // BECAUSE i IS AN INTEGER AND INDEXPATH IS A POINTER
        FOO: oldCell = [myTableView cellForRowAtIndexPath:(int)i];
        // GOOD CODE:
        oldCell = [penanceOptionsTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];
        oldCell.accessoryType = UITableViewCellAccessoryNone;
    }
    UITableViewCell *newCell = [myTableView cellForRowAtIndexPath:indexPath];
    newCell.accessoryType = UITableViewCellAccessoryCheckmark;
}
Run Code Online (Sandbox Code Playgroud)

iphone xcode checkmark

10
推荐指数
4
解决办法
2万
查看次数

标签 统计

checkmark ×1

iphone ×1

xcode ×1