Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS: Autolayout with child view controllers
    primarykey
    data
    text
    <p>I've been using autolayout for a couple of weeks now. Currently, I'm using a 3rd party library called FLKAutoLayout which makes the process easier. I'm at the point where I can construct views the way I want, usually without problem. However, over the past 4 days at work I've been struggling with autolayout once viewcontrollers are involved. I'm fine with all sorts of UIViews... but for some reason, every viewcontroller.view is a total demon. I've had nothing but problems getting a viewcontroller.view to size the way I want and an ever deeper problem is that UIViews of child viewcontrollers do not receive events properly when using autolayout. child viewcontrollers work just fine when designating frames manually, but everything breaks down with autolayout.</p> <p>I don't understand what's so different about a viewcontroller's UIView that makes it different than all the others... My mind is melting in frustration. Is ios messing with my viewcontroller views behind the scenes or something?</p> <p><a href="http://i39.tinypic.com/6qeh3r.png" rel="nofollow noreferrer">sample image http://i39.tinypic.com/6qeh3r.png</a></p> <p>In the image, the red area belongs to a child view controller. This area should not be going past the bottom most subview (the card that says three). This should be easy and I can get it to work just fine with a bunch of normal UIViews but because this is a viewcontroller, everything breaks...</p> <p>Can anyone shed light on what it is I don't know. Any leads on potential issues is much appreciated.</p> <p>Thanks for reading.</p> <p><em>Update: The problem may be related to ambiguous constraints</em></p> <pre><code>UIView *box = [[UIView alloc]init]; [box addSubview:imageView]; [box addSubview:nameLabel]; imageView constrainWidth:@"32" height:@"32"]; [imageView alignTop:@"&gt;=0" leading:@"0" bottom:@"&lt;=0" trailing:@"&lt;=0" toView:box]; [imageView alignCenterYWithView:box predicate:@"0"]; [nameLabel constrainLeadingSpaceToView:imageView predicate:@"5"]; [nameLabel alignTop:@"&gt;=0" leading:@"&gt;=0" bottom:@"&lt;=0" trailing:@"&lt;=0" toView:box]; [nameLabel alignCenterYWithView:box predicate:@"0"]; [self addSubview:box]; [box alignTop:@"5" leading:@"5" bottom:@"-5" trailing:@"-5" toView:self]; </code></pre> <p>The example above is an ambiguous layout but I can't figure out what's wrong with it...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload