【发布时间】:2014-12-03 04:44:21
【问题描述】:
当一个单元格被选中时,我希望它被选中。我还想要任何其他被检查为没有附件的单元格。不幸的是,我收到一条错误消息,提示我无法更改附件类型。那是因为我使用visibleCells() 来获取单元格吗?如何克服这个错误?
我试过不使用常量;我得到了同样的错误。我查看了 UITableView 和 UITableViewCell 类参考,但没有看到任何可以帮助我的东西。我的备用计划是使用 Picker View,但由于它的设计,我更喜欢使用 Table View。
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let cell = tableView.cellForRowAtIndexPath(indexPath)
let cells = tableView.visibleCells()
for oldCell in cells {
if(oldCell.accessoryType == UITableViewCellAccessoryType.Checkmark) {
oldCell.accessoryType = .None //Cannot assign to 'accessoryType' in 'oldCell'
}
}
cell!.accessoryType = .Checkmark
day = cell!.textLabel!.text!
self.tableView.deselectRowAtIndexPath(indexPath, animated: true)
}
【问题讨论】:
标签: ios uitableview swift xcode6.1