1

I am using setFrame to change the X position of my view. I have the views positioned outside of the UIViewController and when I click any of the buttons, it brings in the UIView depending on which button is pressed. I am not sure what I am doing wrong but with the code below none of the views will move, although I had it working before in a previous project so I can't get my head around why it won't work now.

Code for the button is below, thanks!

- (IBAction)reviews {
    [self.descView setFrame:CGRectMake(-378, 278, 375, 334)];
    [self.reviewsView setFrame:CGRectMake(0, 278, 375, 334)];
    [self.avView setFrame:CGRectMake(-378, 278, 375, 334)];
    [self downloadreviews];

}
Curtis Boylan
  • 827
  • 1
  • 7
  • 23

1 Answers1

4

If you use AutoLayout then you can't manipulate your views' frames directly. The constraints take over and move them right back.

You need to set up constraints, connect outlets to those constraints, and then change the constant values on the constraints and call layoutIfNeeded to get the constraints to move/resize your views for you.

Duncan C
  • 128,072
  • 22
  • 173
  • 272