Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView header height will not change in storyboard

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):

enter image description here

Here are my settings:

enter image description here

It looks correct in the storyboard preview. What could be causing it to be so huge and prevent my height setting from working?

like image 591
Nic Hubbard Avatar asked Dec 02 '22 15:12

Nic Hubbard


2 Answers

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.

like image 57
Nic Hubbard Avatar answered Dec 07 '22 00:12

Nic Hubbard


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

like image 26
William Hu Avatar answered Dec 06 '22 23:12

William Hu