如何禁用UITableView的单个单元格的选择?

lil*_*lzz 2 iphone uitableview

一旦用户点击触发操作的单元格,我想禁用用户交互,然后在操作完成后重新启用用户交互.谁能告诉我怎么做?

Aja*_*rma 8

只需检查TableView委托方法中的条件:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *categoryIdentifier = @"Category";
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    //Way to stop to choose the cell selection
     if(indexpath.row == 0){
         cell.selectionStyle = UITableViewCellSelectionStyleNone;
         // OR 
         cell.userInteractionEnabled=False;
     }
     //while rest of the cells will remain active, i.e Touchable

    return cell;

}
Run Code Online (Sandbox Code Playgroud)