我有一个表视图控制器,它实现了 TableView 委托方法:
public override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let cell = tableView.cellForRowAtIndexPath(indexPath) as! ParticipantesSearchTableViewCell
cell.viewModel?.active = true
}
public override func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
let cell = tableView.cellForRowAtIndexPath(indexPath) as! ParticipantesSearchTableViewCell
cell.selectedStateImageView.hidden = true
cell.viewModel?.active = false
}
请注意,我从未删除或将 tableView.editing 设置为 true。还有,我的numberOfRowsInSection
方法永远不会改变。
如果我将 tableView 设置为tableView.allowsSingleSelection = true
我可以很好地选择和取消选择单元格,并且上述方法按预期触发。但是,当我在 tableView 上滚动并选择一个新单元格时,方法 didselectRowAtIndexPath 崩溃let cell = tableView.cellForRowAtIndexPath(indexPath) as! ParticipantesSearchTableViewCell
此时我调试了tableView.indexPathForSelectedRow
它返回零。
知道我在这里实施的错误是什么或者这是否是一个错误?因为我尝试使用同一张表tableView.allowsMultipleSelection = true
我可以很好地选择、取消选择和滚动。
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)