I have a UIView which consists of many dynamic sub views including UIStackView.
I have to add this UIView as my tableFooter, so I need to calculate it’s height. I tried calculated the height with two methods below, but I got incorrect size and zero.
//got incorrect size
let targetSize = CGSize(width: 300, height: UIView.layoutFittingCompressedSize.height)
let prefSizs = footerView.systemLayoutSizeFitting(targetSize)
footer.frame = CGRect(x: 0, y: 0, width 300, height: prefSize.height)
//got zero frame
let frame = footerView.frame
Is there anyway I can find the correct height for my dynamic UIView based on the given width?