我想将多个静态表格 View 单元格的高度更改为零并恢复正常。
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
if reminderHidden && indexPath.section == 1 && indexPath.row == 1 {
return 0
}
else {
return super.tableView(tableView, heightForRowAtIndexPath: indexPath)
}
}
我可以更新 bool 值,上述方法非常适合隐藏一个静态单元格。但返回一个值后就停止了。我想隐藏两个静态单元格并在更改一个 bool 值时使它们恢复正常。
最佳答案
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
if indexPath.row == 1 && toggle.on == false {
return 0.0
}
if indexPath.row == 2 {
if toggle.on == false || pickerVisible == false {
return 0.0
}
return 165.0
}
return 44.0
}
有关更多详细信息,请访问我的博客:
http://blog.apoorvmote.com/how-to-show-and-hide-static-cells-with-uiswitch/
关于ios - 隐藏多个单元格heightForRowAtIndexPath静态tableview swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29014334/