AutoLayout container relative position not recognised under ios8 beta 4
-
20-12-2019 - |
Question
In my view, I init a view like this:
UIView *statsView = [[UIView alloc] initWithFrame:CGRectMake(10, 130, 200, 12)];
Inside this view, I create 3 autolayout subviews contained in this previous view.
for (UIButton* v in [statsView subviews]) {
v.translatesAutoresizingMaskIntoConstraints = NO;
[statsView addSubview:v];
}
NSDictionary *views = @{@"reposts": v1,
@"likes": v2,
@"comments": v3
};
[statsView addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"H:|[reposts][likes][comments]"
options:NSLayoutFormatAlignAllTop| NSLayoutFormatAlignAllBottom
metrics:0
views:views]];
On IOS7 , the Y position of the container is 130 (defined in the initWithFrame), but with ios8, the Y position looks like "0".
Any ideas?
Solution
I ask an other question about the same problem and Saldorino give me a good answer
Xcode6 - Autolayout view in an other autolayout view
The issue lies in the missing the vertical position constraint.
[statsView addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"V:|[comments]"
options:0
metrics:0
views:views]];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow