sheetal sheetal -4 years ago 166
Objective-C Question

UITableViewAutomaticDimension is working but how do I get the frame Size the autolayout set it to?

My Question might sound strange but somehow I need to ask this. So I have UITableViewAutomaticDimension set on my both Section Header and Rows which is working like a charm. But somehow I am playing with constraints which changes my Section Header dynamically(The whole frame and constraints NOT Content when the Table scrolls. IS there a way to get the size or frame that was set to my Section Header while using UITableViewAutomaticDimension

I am not looking for suggestions like why should I not change my constraints at run time. Please help if I can find the auto-layout size set to the headers after my table was loaded.

Answer Source

You can look at the bounds of the view in tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) from UITableViewDelegate and that will be the size that the automatic dimension calculated. Same goes for cells in tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download