[英]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.