在StoryBoard直接删除当然简单啦,可是在业务要求动态显示时,就不一样了,当然,如果没用StoryBoard也好控制,可是偏偏当初做的时间用了StroryBoard
好说,就在这几个方法上动工就行了:
//控制section的个数,如果你要隐藏的 section在末尾,用它就行了
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 6
}
//要隐藏的section,就用用这两个方法,让们的高度为0.1
override func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if(section == 3 ){
return 0.1
}
return super.tableView(tableView, heightForHeaderInSection: section)
}
override func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
if(section == 3 ){
return 0.1
}
return super.tableView(tableView, heightForFooterInSection: section)
}
//另外,控投制section中cell的个数,用这个方法
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if(section == 3 ){
return 0
}
return 1
}