ios6中的自动布局

ios6中的自动布局,ios,Ios,我正在测试添加自动布局约束以编程方式查看。但它隐藏了我的观点。我正在写代码 UIView *testView = [[UIView alloc] initWithFrame:CGRectMake(50.0, 200.0, 600.0, 200.0)]; [testView setBackgroundColor:[UIColor grayColor]]; [self.view addSubview:testView]; [testView setTranslatesAutoresizingMa

我正在测试添加自动布局约束以编程方式查看。但它隐藏了我的观点。我正在写代码

UIView *testView = [[UIView alloc] initWithFrame:CGRectMake(50.0, 200.0, 600.0, 200.0)];
[testView setBackgroundColor:[UIColor grayColor]];

[self.view addSubview:testView];

[testView setTranslatesAutoresizingMaskIntoConstraints:NO];

NSDictionary *views = NSDictionaryOfVariableBindings(testView);

[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-50-[testView(>=600)]-50-|" options:0 metrics:nil views:views]];
为什么要隐藏我的观点?
请帮帮我。谢谢。

您在垂直方向上没有给它任何约束,因此0点的高度满足您给它的所有约束。如果允许,Autolayout喜欢跳转到0