0
分配給「accessoryType」,我希望它進行檢查。我也想要其他任何被檢查的單元沒有附件。不幸的是,我收到錯誤信息,說我無法更改accessoryType。那是因爲我使用visibleCells()
來獲取細胞嗎?我如何克服這個錯誤?不能在UITableViewCell中
我曾嘗試不使用常量;我得到了同樣的錯誤。我看了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)
}