UITableView header section height not called on scroll

Code Block language
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
    
    
    var data = ["abc djak da njdas sajlnakjs casjoas casklcnal csadjsa cnsljanl sd clnsdla ",
                "Sample cell with variable amount of text to demostrate the dynamic height of for the cell.",
                "Sample cell with variable amount of text to demostrate the dynamic height of for the cell. --- Sample cell with variable amount of text to demostrate the dynamic height of for the cell.",
                "Sample cell with variable amount of text to demostrate the dynamic height of for the cell. --- Sample cell with variable amount of text to demostrate the dynamic height of for the cell.--- Sample cell with variable amount of text to demostrate the dynamic height of for the cell. --- Sample cell with variable amount of text to demostrate the dynamic height of for the cell.", "Sample cell with variable amount of text to demostrate the dynamic height of for the cell.", "abc djak da njdas sajlnakjs casjoas casklcnal csadjsa cnsljanl sd clnsdla ",
                "Sample cell with variable amount of text to demostrate the dynamic height of for the cell.",
                "Sample cell with variable amount of text to demostrate the dynamic height of for the cell. --- Sample cell with variable amount of text to demostrate the dynamic height of for the cell.",
                "Sample cell with variable amount of text to demostrate the dynamic height of for the cell. --- Sample cell with variable amount of text to demostrate the dynamic height of for the cell.--- Sample cell with variable amount of text to demostrate the dynamic height of for the cell. --- Sample cell with variable amount of text to demostrate the dynamic height of for the cell.", "Sample cell with variable amount of text to demostrate the dynamic height of for the cell.",
                "abc djak da njdas sajlnakjs casjoas casklcnal csadjsa cnsljanl sd clnsdla ",
                            "Sample cell with variable amount of text to demostrate the dynamic height of for the cell.",
                            "Sample cell with variable amount of text to demostrate the dynamic height of for the cell. --- Sample cell with variable amount of text to demostrate the dynamic height of for the cell.",
                            "Sample cell with variable amount of text to demostrate the dynamic height of for the cell. --- Sample cell with variable amount of text to demostrate the dynamic height of for the cell.--- Sample cell with variable amount of text to demostrate the dynamic height of for the cell. --- Sample cell with variable amount of text to demostrate the dynamic height of for the cell.", "Sample cell with variable amount of text to demostrate the dynamic height of for the cell."
    ]
    @IBOutlet weak var tableView: UITableView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        
        // Register the custom header view.
        let nib1 = UINib.init(nibName: "HSimpleSectionHeaderTypeTwoView", bundle: nil)
           tableView.register(nib1, forHeaderFooterViewReuseIdentifier: "sectionHeader") //(HSimpleSectionHeaderTypeTwoView.self, forHeaderFooterViewReuseIdentifier: "sectionHeader")
        let nib = UINib.init(nibName: "CustomTableViewCell", bundle: nil)
        tableView.register(nib, forCellReuseIdentifier: "CustomTableViewCell")
        
        tableView.rowHeight = UITableView.automaticDimension
        tableView.estimatedRowHeight = 100
        
        //tableView.sectionHeaderHeight = 50
        //tableView.estimatedSectionHeaderHeight = 50
    }
    func numberOfSections(in tableView: UITableView) -> Int {
        12
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        data.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "CustomTableViewCell") as! CustomTableViewCell
        
         
        cell.setCell(text: data[indexPath.row])
         return cell
    }
    
    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        let view = tableView.dequeueReusableHeaderFooterView(withIdentifier:
                       "sectionHeader") as! HSimpleSectionHeaderTypeTwoView
           view.title = data[section]
           return view
    }
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        let feedHeaderView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "sectionHeader") as! HSimpleSectionHeaderTypeTwoView
        feedHeaderView.title = data[section]
       return feedHeaderView.height
    }
}

I am suppose to return dynamic height for header based on current text for section, but on scrolling table view i am not getting call in heightForSection method. But As per doumentation It should call the heightForHeader delegate method.

UITableView header section height not called on scroll
 
 
Q