I'm not sure, but the following should work, or something very similar:
UIView *superview = self.view; UIView *childview = cvc.view; NSDictionary *constrainedViews = NSDictionaryOfVariableBindings(childview); NSArray *constraints = [superview addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[childview]-25-|" options:0 metrics:nil views:constrainedViews];
If you are not convinced that you are actually setting the size for the childview, follow these steps:
UIView *superview = self.view; UIView *childview = cvc.view; NSDictionary *constrainedViews = NSDictionaryOfVariableBindings(childview); NSArray *constraints = [superview addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[childview]|" options:0 metrics:nil views:constrainedViews];
Say it fills the width of the view. Or:
UIView *superview = self.view; UIView *childview = cvc.view; NSDictionary *constrainedViews = NSDictionaryOfVariableBindings(childview); NSArray *constraints = [superview addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[childview(>100,<304)]-|" options:0 metrics:nil views:constrainedViews];
This means that something like childview should have a width greater than 100, but less than 304 with default fields for the supervisor. Please note that I donβt know whether the specified restriction really makes sense (for example, it can always give you a 304-width childview, as this will leave the fields default), but this serves as an example.
Diziet
source share