【发布时间】:2014-07-28 18:29:11
【问题描述】:
在我看来,我会像这样初始化一个视图:
UIView *statsView = [[UIView alloc] initWithFrame:CGRectMake(10, 130, 200, 12)];
在这个视图中,我创建了 3 个包含在前一个视图中的自动布局子视图。
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]];
在 IOS7 上,容器的 Y 位置是 130(在 initWithFrame 中定义),但在 ios8 上,Y 位置看起来像“0”。
有什么想法吗?
【问题讨论】:
-
这里也一样。你能想出什么办法吗?
标签: objective-c position autolayout ios8 nslayoutconstraint