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”

  • 相关阅读:
    vue.js加入购物车小球动画
    商品数量编辑按钮3D效果动画
    box-sizing 属性
    Vue中better-scroll插件的使用
    显示从右滑进,隐藏向左滑出效果
    设置宽高等比的盒子
    star组件
    添加模糊效果demo
    c# SSH ,SFTP
    WPF 嵌入winform 控件
  • 原文地址:https://www.cnblogs.com/submarinex/p/2787708.html
Copyright © 2011-2022 走看看