1

This issue is really frustrating and getting me crazy.

I've read everything about AutoLayout and so on, but it happens all the time. My interface has a view with an image view as background and a smaller subview on top of it (corresponding to a field in my image). I've tried everything but it looks like the subview does not scale accordingly with my image when switching through devices. By the way, the IB preview does not show what i real get when running the iOS Simulator, is that normal? Why? What do i do wrong? I'm not sure what else to try!

http://i58.tinypic.com/34xqtc6.png

EDIT: i cannot post images :(

Massimo Polimeni
  • 4,826
  • 4
  • 27
  • 54
  • the information which you provided is not enough to understand you problem, if you could post images regarding your problem that would be good, if that is not possible could you set up a github repo with you issue, i would gladly have a look – Usama Aug 20 '15 at 15:39
  • Hi Usama. i posted a link to a pic above. Let me know if it is clear enough otherwise i'll try to set up a Github repo – Cristiano Esposito Aug 20 '15 at 15:55

2 Answers2

5

I have setup a githubrepo regarding your case, kindly have a look https://github.com/usamaiqbal83/TestingProject

enter image description here

Constraints for Background Image View:

enter image description here

Constraints for Front View

enter image description here

the most important thing to remember is ofcourse the constraint equation

FirstItem.Attribute1 = (SecondItem.Attribute2 * Multiplier) + Constant

Usama
  • 1,945
  • 1
  • 13
  • 20
2

Instead of subview use Container View.

enter image description here

IamMashed
  • 1,811
  • 2
  • 21
  • 32
  • Still showing a displacement :( Can you please suggest me the best way to use constraints in this case? thank so much – Cristiano Esposito Aug 20 '15 at 16:50
  • Can you pick another image as your background? Make it all blue and only then add a white square as another view. You can make round corners of this white square with whitesquare.layer.cornerRadius = 4.0 etc. – IamMashed Aug 20 '15 at 17:14
  • Try drawing the frame manually for each screen size. In simulated metrics choose iPhone 4. Place your view and write down the origin, width and height parameters. Do same for iPhone 5 and 6. Later in viewdidload, if view.frame.height = 536.0 make my view with parameters for iPhone 5. Etc. – IamMashed Aug 20 '15 at 17:25