如何在编辑模式下在UITableView中选择多行?

11 uitableview multipleselection ios swift

我想问一下,当我点击右上角的按钮"选择"时,我可以转发到编辑模式,我可以选择多行,例如在消息应用中,当您可以通过点击圆圈选择多个消息时.

像这样:

在此输入图像描述

我搜索了很多,真的,但找不到任何东西.谁能帮我?一些建议

Leo*_*Leo 44

tableView.allowsMultipleSelectionDuringEditing = true
Run Code Online (Sandbox Code Playgroud)

截图

演示代码

class TableviewController:UITableViewController{
    override func viewDidLoad() {
        super.viewDidLoad()
        tableView.allowsMultipleSelectionDuringEditing = true
        tableView.setEditing(true, animated: false)
    }
    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath)
        cell.textLabel?.text = "\(indexPath.row)"
        return cell
    }
    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 10
    }
}
Run Code Online (Sandbox Code Playgroud)


Isl*_* Q. 7

如果您正在使用Storyboard,请执行以下操作:

在此输入图像描述