TableView header section disappear swift

Problem:

I had tried the following code for tableview header for cell reused but sometimes the header disappears.

func tableView(_ tableView: UITableViewviewForHeaderInSection section: Int) -> UIView? {

    let myCell = table.dequeueReusableCell(withIdentifier"myCell"as! myCell

      return myCell

}


 Solution:

You can use the below code to solve the issue.

func tableView(_ tableView: UITableViewviewForHeaderInSection section: Int) -> UIView? {

    let myCell = table.dequeueReusableCell(withIdentifier"myCell"as! myCell

      return myCell.contentView // This line changes for solving

}


Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

store cgpoint in userdefaults iOS swift