0

I have new issue related to Auto-Layout world , i can summarize the problem in the below steps:

1- I have storyboard with only one scene contain UIImageView .

2- I went to viewcontroller.m file and add manual constraints like below code

[self.bgImageView setTranslatesAutoresizingMaskIntoConstraints:NO];


NSLayoutConstraint *horizentalSpaceConstraint = [NSLayoutConstraint constraintWithItem:self.bgImageView
                                                                         attribute:NSLayoutAttributeTrailing
                                                                         relatedBy:NSLayoutRelationEqual
                                                                            toItem:self.view
                                                                         attribute:NSLayoutAttributeBottom
                                                                        multiplier:1.0
                                                                          constant:0.0]; 
[self.view addConstraint:horizentalSpaceConstraint];

Result :

The constraint didn't affect the IBoutlet for UIImageView but if i add UIImageView from hard coded in viewcontroller.m file it works ,can you help me to discover this problem.

4

1 回答 1

0

我找到了可以通过以下方式描述的解决方案(使用 IBOutlet 元素的每个约束都应在开始之前仅添加以下行,而无需 [setTranslatesAutoresizingMaskIntoConstraints :否]

-(void)viewWillAppear:(BOOL)animated{

    // Step 1 remove view constraints for IBOutlet elements  

    [self.view removeConstraints:self.view.constraints];
}
于 2014-05-26T07:00:04.657 回答