I’m attempting to adjust the size of a UIImageView dependent on whether the device is an iPhone 5 (tall screen) or an earlier iPhone version (shorter screen). Below is my code. However when I run the app these instructions are ignored. I suspect the problem is caused by auto layout constraints. If I turn those constraints off the image is resized but that messes up the rest of my layout. Is there anyway to selectively override auto layout rather than turning it off?
CGRect screenBounds = [[UIScreen mainScreen] bounds];
if (screenBounds.size.height == 568) {
// code for 4-inch screen
avatarImage.frame = CGRectMake(43, 372, 75, 75);
} else {
// code for 3.5-inch screen
avatarImage.frame = CGRectMake(43, 372, 50, 50);
}
EDIT
Below is an image of the problem I am trying to solve. I want the avatar image to resize proportionally until it fits in the smaller view. And I want to programmatically move the text field up and to the right of the label.


One way to do this would be to programmatically alter your constraints. You can do this by:
Create height and width constraints for your imageview by selecting the image view, and then in Xcode 5, clicking on the
button:
Or, in the prior versions of Xcode, by clicking on the
button:
Make sure to change the other, secondary, constraints work permit the resizing of the imageview. For example, if you have a label to the right of this thumbnail image, you want to make sure that it is set up so the width of the label will adjust as the size of the image changes. Bottom line, you want to make sure you don’t have constraint conflicts when the app runs, because if you do have some conflicts, you may get a debugging message about having to break a constraint to make the app work, or worse, that the constraints are not satisfiable.
Create
IBOutletreferences for your new height and width constraints. The easiest way is to show the assistant editor (so your associated .h files show up while you’re manipulating your storyboard) and then control-drag from the constraint to the .h file:Then in your code, you can alter your constraints: