Re: Constraints Question
Re: Constraints Question
- Subject: Re: Constraints Question
- From: Jonathan Hull <email@hidden>
- Date: Sat, 29 Sep 2012 16:12:20 -0700
You probably want to set the content hugging priority of the button to a lower value (probably UILayoutPriorityDefaultLow). By default, buttons have an intrinsic constraint that says they don't like to grow vertically (it likes to "hug" its content strongly in the vertical direction).
[myButton setContentHuggingPriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisVertical];
Thanks,
Jon
On Sep 29, 2012, at 2:52 PM, Eric Gorr <email@hidden> wrote:
> I am trying to wrap my head around the auto-layout functionality.
>
> I have a sample project at:
>
> http://ericgorr.net/cocoadev/constraints.zip
>
> After opening the project, take a look at ELGFirstViewController.xib.
>
> This app will only be used in landscape.
>
> On this XIB, there are three objects.
>
> (1) A button
> (2) A label
> (3) A Table View
>
> What I am looking to do is the following:
>
> 1. I want the table view to be a fixed height of 648 pixels. It should be the full width of it's superview and anchored at the bottom.
> 2. The label should be immediately above the table, with no vertical separation between it and the table view. It should also be the full width of the superview and it's height should remain fixed.
> 3. The button should be located at the right, with no vertical separation between it and the label. There should be no vertical separation between it and top of the super view. The height of the button is what I would like to be variable.
>
> I have tried playing around with the height constraint of the button, lowering it's priority, but in every case, it is the height of the table view that shrinks.
>
> How can I set up the constraints so the height of the button is variable? Is this possible to specify within IB or is the something I will need to do in code?
>
>
>
> I can, of course, just fix the height of the button since I know how many pixels I will have remaining, but, again, I was interesting in learning something about auto-layout and was having trouble resolving this problem.
>
>
> Thank you.
>
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden