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

标签 iphone uitableview

一旦用户点击触发操作的单元格,我想禁用用户交互,然后在操作完成后重新启用用户交互。有人可以告诉我该怎么做吗?

最佳答案

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

- (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;

}

关于iphone - 如何禁用 UITableView 的单个单元格的选择?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6318251/

相关文章:

ios - 自定义单元格按钮单击

ios - 如何向用户显示 UITableViewCell 滑动操作的预览

UITableView cellforrowatindexpath 未调用

ios - TableView 中无法删除显示消息行

iPhone 应用程序试用期

iphone - core-plot:仍然不明白如何拥有自定义标签和刻度

iphone - 如何检查 Xcode 4 中未使用的变量

iphone - 退出并尝试返回应用程序时出现问题

iphone - 通用应用程序加载不同的 View

objective-c - 在 UITableViewCell 上绘制阴影