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.

wod
  • 812
  • 1
  • 10
  • 23

1 Answers1

0

I found the solution which can describe by ( Every constraints used IBOutlet elements should before begin add only the below line without need to [setTranslatesAutoresizingMaskIntoConstraints :No]

-(void)viewWillAppear:(BOOL)animated{

    // Step 1 remove view constraints for IBOutlet elements  

    [self.view removeConstraints:self.view.constraints];
}
wod
  • 812
  • 1
  • 10
  • 23