![](/img/trans.png)
[英]How check one cell of tableView and uncheck rest of the cells in the section in swift
[英]How to check tableview cell is row or section in swift?
在目标C中,我曾经像下面这样检查
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (!indexPath.row) {
NSLog(@"section");
} else {
NSLog(@"row");
}
}
如何用Swift做同样的事情?
indexPath.row并不意味着一节。 您可以通过编写indexPath.section获得节索引。 试想一下2D阵列。 每个部分都有自己的行。 试想一下。 希望能帮助到你。
Swift不会自动将整数转换为布尔值。 您需要使测试明确: if indexPath.row != 0 { ... }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.