【问题标题】:How to disable the row selection after specific no of counts in UItableview如何在 UItableview 中的特定计数后禁用行选择
【发布时间】:2013-08-28 14:47:13
【问题描述】:

我想在多选 UITableView 中选择 10 行后禁用 UITableView 单元格选择, 再次取消选择某些行后,用户将能够选择 UITableView 单元格。

谁能给我建议,我该怎么做?

提前感谢您的帮助。

【问题讨论】:

    标签: iphone uitableview


    【解决方案1】:

    实现willSelectRowAtIndexPath:indexPath:

    - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
      if (tableView.indexPathsForSelectedRows.count < YourMaxRowSelectedCount) {
        return indexPath;
      } else {
        return nil;
      }
    }
    

    【讨论】:

      【解决方案2】:

      indexPathsForSelectedRows 方法返回一个NSArray 对象,该对象包含表视图中所有选定行的索引路径。您可以检查该计数以与所需的选定行数进行比较并采取相应措施。

      【讨论】:

      • 您好,感谢您的快速回复,但我已使用上述答案及其工作。
      猜你喜欢
      • 1970-01-01
      • 2010-09-16
      • 2020-12-24
      • 1970-01-01
      • 2021-10-31
      • 1970-01-01
      • 1970-01-01
      • 2019-12-08
      • 1970-01-01
      相关资源
      最近更新 更多