UITableView怎么在非Editing状态下多选

2018-09-30  本文已影响0人  踏雪无痕11911

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
上一篇 下一篇

猜你喜欢

热点阅读