Saya mencoba mengganti bingkai yang ditetapkan dengan batasan untuk UIButton tetapi kode saya terus mogok, apa yang saya lakukan salah?
- (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;
sebelum menambahkan batasan. - person AnthonyR   schedule 26.05.2016self.myButton
alih-alihself.Button
di awal kode Anda - person AnthonyR   schedule 26.05.2016