I have a Storyboard
that is using a UITableViewController
. I have added a UIView
as the UITableView
header and set the height to 200. But, for some reason, when I preview it, the header is huge! looks to be about 540 high (header is white):
Here are my settings:
It looks correct in the storyboard preview. What could be causing it to be so huge and prevent my height setting from working?
Apple figured it out. Here is what they said:
Because the frame of a view can not be customized per-size class, you need to make changes to your header view's frame while editing the [wAny hAny] size class.
I was in the [wCompact hRegular] mode, which apparently you cannot set frame sizes in.
Just solved this question, try this:
UIView *v = self.tableView.tableHeaderView;
CGRect fr = v.frame;
fr.size.height = [UIScreen mainScreen].bounds.size.height -100;
v.frame = fr;
[self.tableView updateConstraintsIfNeeded];
Can't set constraints of UItableView's tableHeaderView height by autolayout in Storyboard
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With