Hi,
I have created custom headers which has buttons which will be used across the entire app
Also in the tableview we have textviews so i need to resize and scroll
When i do that all the headerviews go blank
For headerview i am passing a uitableviewcell, since it needs a view
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
guard let cell1 = tableView.dequeueReusableCell(withIdentifier: "header") as? CustomCell else {
return UITableViewCell()
}
cell1.delegate = self
cell1.btnHeader.setTitle("Test", for: .normal)
return cell1
On textview did change i call the following code
let size = textView.bounds.size
let newSize = textView.sizeThatFits(CGSize(width: size.width, height: CGFloat.greatestFiniteMagnitude))
/
if size.height != newSize.height {
UIView.setAnimationsEnabled(false)
tableView?.beginUpdates()
tableView?.endUpdates()
UIView.setAnimationsEnabled(false)
guard let cell = textView.superview?.superview?.superview as? CustomCell else {
return
}
if let thisIndexPath = tableView?.indexPath(for: cell) {
tableView?.scrollToRow(at: thisIndexPath, at: .bottom, animated: false)
}
}