Я пытаюсь заменить установленный фрейм ограничениями для UIButton, но мой код продолжает падать, что я делаю неправильно?
- (void)CreateButton {
self.Button = [[UIButton alloc] init];
//self.Button.frame = CGRectMake(30, 30, 100, 100);
[self.Button addConstraint:[NSLayoutConstraint constraintWithItem:MyScrollView
attribute:NSLayoutAttributeTop
relatedBy:NSLayoutRelationEqual
toItem:self.myButton
attribute:NSLayoutAttributeTop
multiplier:2.0
constant:30]];
[self.myButton addConstraint:[NSLayoutConstraint constraintWithItem:MyScrollView
attribute:NSLayoutAttributeHeight
relatedBy:NSLayoutRelationEqual
toItem:self.myButton
attribute:NSLayoutAttributeHeight
multiplier:3.0
constant:50]];
[self.myButton setBackgroundColor:[UIColor orangeColor]];
[self.myButton setTitle:@"Press Me" forState:UIControlStateNormal];
[self.myButton setTitleColor:[UIColor purpleColor] forState:UIControlStateNormal];
[MyScrollView addSubview:self.myButton];
self.myButton.view.translatesAutoresizingMaskIntoConstraints = NO;
перед добавлением ограничений. - person AnthonyR   schedule 26.05.2016self.myButton
вместоself.Button
в начале своего кода. - person AnthonyR   schedule 26.05.2016