I created a tableview and i have 2 sections. in second section i need a header . so i did this like below.
func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if section == 1 {
return 40
}
return 0
}
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if section == 1 {
let header = tableView.dequeueReusableCellWithIdentifier("audiocellheader")! as UITableViewCell
return header
}
else {
return nil
}
}
I have a problem when i reload the section.Header get disappeared.if i do tableview.reload its works fine. what will be the issue?. Also i have an issue when i delete the item in the cell. image is given below.
header get moves as same as edited row.
I checked the link from here Swipe to delete cell causes tableViewHeader to move with cell got the answer.
instead of cell return cell.contentview.both issue resolved
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if section == 1 {
let header = tableView.dequeueReusableCellWithIdentifier("audiocellheader")! as UITableViewCell
return header.contentView
}
else {
return nil
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.