UITableView怎么在非Editing状态下多选

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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容