0

I have a view controller that contains a custom view with a UITableView just below it.

I am trying to figure out how I can make the table view resize to fill up the remaining space, when I change the height of the custom view in code. I want this done using auto-layout constraints!

And on top of the for some reason I cannot programatically resize the height of a custom view made with storyboard, when I do nothing happens.

Auto-layout is both evil and amazing. Please help me!

DBoyer
  • 3,062
  • 4
  • 22
  • 32
  • Did you use setFrame: to resize the custom view? If it has auto layout constraint setFrame: is not working. – Ryan Jul 18 '14 at 02:01
  • Yes I used setFrame, so does setFrame get ignored totally if a constraint is set on the view? Does that mean you need to make an IBOutlet for the height constraint and do it that way? – DBoyer Jul 18 '14 at 02:03
  • Yes. One more thing you can do here. Check this. http://stackoverflow.com/questions/13186908/can-i-use-setframe-and-autolayout-on-the-same-view – Ryan Jul 18 '14 at 02:07
  • Wow, thanks I have never heard of that property before so I will give that a try! – DBoyer Jul 18 '14 at 02:09
  • I still can't get the result I want, auto-layout is just not cool sometimes. – DBoyer Jul 18 '14 at 02:16
  • Auto-layout is pretty good method. It just takes time to get familiar with. – Ryan Jul 18 '14 at 02:18

1 Answers1

1

To resize auto layout views. You have to modify constraint's value.

I assume you already have constraints like below.
Make IBOutlet of NSLayoutConstraint in your view controller:

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *headerHeightConstraint;

Connect header view's height constraint to it.
then, you can resize height of header view with:

headerHeightConstraint.constant = 100.0f;

screenshot

rintaro
  • 51,423
  • 14
  • 131
  • 139