0
Swiftでスイッチを切り替えると、静的テーブルの行とセクションヘッダーを表示/非表示にしようとしています。私は行を非表示にすることができますが、1つのセクションヘッダービューを非表示にしようとすると、トグルを再びオンにするともう一方が消えていきます。私は何をしないのですSwiftで静的セクションヘッダーを非表示/表示する
@IBAction func toggleSound(sender: UISwitch) {
if(sender.on) {
self.sectionInVisible = false
}
else{
self.sectionInVisible = true
}
let section = 1
let secPath = NSIndexPath(forRow: 1, inSection: 0)
self.tableView.cellForRowAtIndexPath(secPath)?.hidden = sectionInVisible
self.tableView.headerViewForSection(section)?.hidden = sectionInVisible
let numberOfRows = tableView.numberOfRowsInSection(section)
for row in 0..<numberOfRows {
let path = NSIndexPath(forRow: row, inSection: section)
tableView.cellForRowAtIndexPath(path)?.accessoryType = .None
tableView.cellForRowAtIndexPath(path)?.hidden = sectionInVisible
}
self.tableView.reloadData()
}
:
これは私のコードは次のようになりますか?私も高さを変更しようとしましたが、静的なテーブルでは機能しないと思います。