zoukankan      html  css  js  c++  java
  • 控制表视图中部分UITableViewCell不可选

    首先保证:

    1 self.tableView.allowsSelection = YES;  // 默认是 YES
    2 self.tableView.allowsSelectionDuringEditing = YES;

    UITableView中的声明:

    1 @property(nonatomic) BOOL allowsSelection __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);  // default is YES. Controls whether rows can be selected when not in editing mode
    2 @property(nonatomic) BOOL allowsSelectionDuringEditing;                                     // default is NO. Controls whether rows can be selected when in editing mode

    ===========================================================================================

    对于具体的UITableViewCell在不同时期的可选性单独控制,假设根据 [Edit/Done] editButtonItem 控件分别控制cell0,cell1:

    实现 UITableView Delegate 中的 tableView:willSelectRowAtIndexPath: 方法

     1 - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath 
     2 {
     3     NSInteger row = indexPath.row;
     4     BOOL editing = self.editing;
     5     
     6     if ( (editing && row == 0) || (!editing && row == 1) ) {
     7         [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
     8         return nil;
     9     }
    10     return indexPath;
    11 }

    参考:UITableView Setting some cells as “unselectable”

  • 相关阅读:
    java实现同步的两种方式
    JAVA线程概念
    XML基础总结
    JAVA使用和操作properties文件
    JAVA序列化基础知识
    easyui 在编辑状态下,动态修改其他列值。
    Activiti初学问题,求解
    java web--DOM
    java web(1)
    Java WEB
  • 原文地址:https://www.cnblogs.com/submarinex/p/2787708.html
Copyright © 2011-2022 走看看