Tag: 快捷复选

点击SWIFT时,将打开和closuresUItableviewcell对勾

我正在做一个tableview 我希望能够点击每个单元格,当点击时,它会在单元格上显示一个复选标记 现在我有一些代码,使这项工作: // checkmarks when tapped func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { let section = indexPath.section let numberOfRows = tableView.numberOfRowsInSection(section) for row in 0..<numberOfRows { if let cell = tableView.cellForRowAtIndexPath(NSIndexPath(forRow: row, inSection: section)) { cell.accessoryType = row == indexPath.row ? .Checkmark : .None } } } 但是这段代码只select了一个段内的1个单元(我有5个段) 我需要它在任何地方select任何单元格 另外,当我拖动我的屏幕上下,我失去了复选标记 任何帮助将非常感激 viewcontroller.swift class ViewController: […]