I need to create a section header for a tableview, and I don't want to create it in single Xib, I added one in storyboard, but the header need some customization, so I create a file looks like this:
And I want to use the header in viewForHeaderInSection func like this:
if I register the cell, it crash, if not, the cell always returns nil.
Do I have to use the UITableViewCell instead of simple CustomizedTipsView for view from storyboard?
Thank you for your help!
Code Block class CustomizedTipsView: UITableViewHeaderFooterView { @IBOutlet weak var tipTitle: UILabel! @IBOutlet weak var tipContent: UILabel! }
And I want to use the header in viewForHeaderInSection func like this:
Code Block if let header = tableView.dequeueReusableHeaderFooterView(withIdentifier: "CustomizedTipsView") as? CustomizedTipsView { header.tipTitle.text = "1" header.tipContent.text = "2" }
if I register the cell, it crash, if not, the cell always returns nil.
Code Block //crash mainTableView.register(UINib(nibName: "CustomizedTipsView", bundle: nil), forHeaderFooterViewReuseIdentifier: "CustomizedTipsView") //crash too mainTableView.register(CustomizedTipsView.self, forHeaderFooterViewReuseIdentifier: "CustomizedTipsView")
Do I have to use the UITableViewCell instead of simple CustomizedTipsView for view from storyboard?
Thank you for your help!