4
votes

I am working on an app that targets only iOS 6 and I use nib files for the UI (not a storyboard).

I have a view in a view controller which contains a UIImageView as a subview. I need that the size of the image is 320x320 on both Retina 3.5 and Retina 4 screens.

I began designing the view in IB with the size of the Retina 4 Full Screen. I've dropped the UIImageView on my view and set it's size to 320x320. Then I pinned the height of the image view to a constraint equal to 320. At this point in time the constraint changed to a user constraint (i.e. it is blue instead of purple).

The other constraints affecting the image view are:

  • Trailing Space to: Superview is 0
  • Leading Space to: Superview is 0
  • Top Space to: Superview is 0

So there is no Bottom Space to: Superview constraint defined.

Now the problem appears if I switch the Size of the view (in the Simulated Metrics) to Retina 3.5 Full Screen.

When I do this, the Height constraint of the image view changes to purple and to 232.

I don't know how to fix this problem. I would like the height to stay at 320. I thought this would be influenced by the Bottom Space to: constraint, but given that there isn't any defined, why does the height of the image view change?

Thanks in advance!

1

1 Answers

0
votes

Just created a test project to recreate your scenario. I didn't have any difficulties. See screenshots below for simulated metrics retina 3.5" and retina 4".

Btw I know this isn't an answer but it does allow me to include the screen grabs.

As you can see the image size is maintained at 320 x 320 in Xcode. It also works ok on the simulator. The top, leading, and trailing constraints are zero. No bottom constraint is specified.

Makes me think you must have something else happening? Could you post a grab of your Xcode window?

enter image description here

enter image description here