【发布时间】:2018-03-25 19:50:36
【问题描述】:
我致力于 tableview 功能,以便在选择 tableview 单元格时,tableview 重新加载并在所选行中显示复选标记。所选行未突出显示,并且不允许选择多行。
在 iOS 11 中,它按预期停止工作。我希望选定的行显示一个复选标记。另外,所选行的背景不应突出显示,并且不允许选择多行。
func tableView(_ tableView: UITableView, cellForRowAtIndexPath indexPath: IndexPath) -> UITableViewCell {
let clientCell = tableView.dequeueReusableCell(withIdentifier: "clientCell", for: indexPath)
clientCell.selectionStyle = .none
if selectedIdxPath == indexPath.row {
clientCell.accessoryType = UITableViewCellAccessoryType.checkmark
} else {
clientCell.accessoryType = UITableViewCellAccessoryType.none
}
return clientCell
}
func tableView(_ tableView: UITableView, didSelectRowAtIndexPath indexPath: IndexPath) {
selectedIdxPath = indexPath.row
tableView.reloadData()
}
【问题讨论】:
标签: uitableview ios11 xcode9 swift4