0
我嘗試爲UIview添加IBOutlet屬性的約束,但它似乎不起作用。而且我還將TranslatesAutoresizingMaskIntoConstraints設置爲no。爲什麼不能爲故事板中創建的UIView添加約束?
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.\
[_view1 setTranslatesAutoresizingMaskIntoConstraints:NO];
NSDictionary *views = NSDictionaryOfVariableBindings(_view1);
[self.view addConstraints:
[NSLayoutConstraint constraintsWithVisualFormat:@"V:[_view1(40)]-30-|"
options:0
metrics:nil
views:views]];
[self.view addConstraints:
[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-10-[_view1(30)]"
options:0
metrics:nil
views:views]];
}
我該怎麼做才能糾正它?
我還沒有在故事板上添加約束,以確保我有明確的情節串連圖板制約。它沒有工作。 – 2014-11-05 01:40:17