2013-04-06 81 views
0

我正在測試添加自動佈局約束以編程方式查看。但它隱藏了我的觀點。我正在寫代碼...ios6中的Autolayout

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

你還沒有給出它在垂直方向上的任何約束,所以0點的高度滿足你給它的所有約束。如果你願意,Autolayout喜歡跳到0。