tableView 实现单选可取消

2017/11/26 TableView
  1. 设置 self.allowsMultipleSelection = YES;
  2. 在 willSelectRowAtIndexPath 添加取消逻辑
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    //实现单选取消逻辑
    NSArray *indexPaths = [tableView indexPathsForSelectedRows];
    if (indexPaths.count > 0) {
        for (NSIndexPath *indexPath in indexPaths) {
            [tableView deselectRowAtIndexPath:indexPath animated:YES];
        }
    }
    return indexPath;
}

Search

    Table of Contents