我正在尝试检测 cellForRowAtIndexPath
中是否选择了 UITableViewCell
。这是我到目前为止对 objective-c 所做的:
UITableViewCell *cell = [tableView cellForRowAtIndexPath:someIndexPath];
if(cell.isSelected) {
NSlog(@"This cell is selected")
}
我无法在 Swift 中访问 UITableviewCell
的属性 isSelected
。我如何实现这一目标?
最佳答案
if cell.selected {
是正确的方法。
if let cell = tableView.cellForRowAtIndexPath(someIndexPath) {
if cell.selected {
print("This cell is selected")
}
}
if let cell = tableView.cellForRow(at: someIndexPath) {
if cell.isSelected {
print("This cell is selected")
}
}
关于ios - 在 Swift 中的 cellForRowAtIndexPath 中的 UITableView 中选择检测单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36810765/