美文网首页
UITableView怎么在非Editing状态下多选

UITableView怎么在非Editing状态下多选

作者: 踏雪无痕11911 | 来源:发表于2018-09-30 14:05 被阅读0次

UITableView单选多选使我们经常使用的,使用系统的多选打开UITableView的Editing,然后使用系统的那个蓝色勾选更是用的普遍。那么不打开编辑状态,怎么实现多选呢?

其实只需要一个属性,就是allowsMultipleSelection,核心代码如下:

self.tableView.allowsMultipleSelection = YES;

注意看UITableView的以下属性:

@property (nonatomic) BOOL allowsSelection NS_AVAILABLE_IOS(3_0);  // default is YES. Controls whether rows can be selected when not in editing mode
@property (nonatomic) BOOL allowsSelectionDuringEditing;                                 // default is NO. Controls whether rows can be selected when in editing mode
@property (nonatomic) BOOL allowsMultipleSelection NS_AVAILABLE_IOS(5_0);                // default is NO. Controls whether multiple rows can be selected simultaneously
@property (nonatomic) BOOL allowsMultipleSelectionDuringEditing NS_AVAILABLE_IOS(5_0);   // default is NO. Controls whether multiple rows can be selected simultaneously in editing mode
Simulator Screen Shot - iPhone 8 - 2018-09-30 at 13.48.33.png

相关文章

网友评论

      本文标题:UITableView怎么在非Editing状态下多选

      本文链接:https://www.haomeiwen.com/subject/sorwoftx.html