2

My views fit fine on the iphone6 but not the iphone4. My immediate reaction is to programmatically detect which iPhone is being used and adjust the font size and button size accordingly but with size classes, and auto-layout this no longer feels right, the same applies to creating multiple storyboards.

I've put in auto-layout constraints and have size classes activated. Is there a way of fixing this using interface builder rather than manually coding each view to fit to each specific device?

iPhone 4s and 6s Screen shots

iPhone 4s ScreenshotiPhone 6s Screenshot

Constraints

Constraints Screenshot

I'm using containers and multiple viewControllers which may complicate things.

Xcode View

Declan McKenna
  • 4,321
  • 6
  • 54
  • 72
  • You should be able to do this with auto layout. The only issue I see in your screenshot's is the phone image on the bottom. Set the aspect-ratio in auto layout and the top and bottom space and it will resize accordingly. – MSU_Bulldog Nov 18 '15 at 16:39
  • @MSU_Bulldog It appears to ignore my superview vertical space constraints when I attempt this and sends my text offscreen. – Declan McKenna Nov 18 '15 at 17:03
  • If I did manage to crush the image down would the font size not remain the same size without code? – Declan McKenna Nov 18 '15 at 17:08
  • You must have some conflicting constraints. Delete those that aren't blue (the light shade of blue) because they aren't even being used. There are a few things you will need to do to fix your constraints. My suggestion is to start by adding the sizeToFit method for the font on your label. And its not crushing the image down, its resizing it to keep its same aspect-ratio but lowing the height and width to fit the container. – MSU_Bulldog Nov 18 '15 at 17:18
  • @MSU_Bulldog All the lines are blue and I have auto-shrink font enabled. I've updated my question with more information which may be relevant. I'm working from containers that each have their own view-controller as pictured. – Declan McKenna Nov 18 '15 at 17:27
  • Using containers won't make any difference. Just set a fixed height for each of the three labels, set the top label's top space constraint to top of its's container, set the bottom label's bottom space constraint to the bottom of it's container, set the aspect ratio of the image, and set spacing between each of your objects. It will resize if you do this. – MSU_Bulldog Nov 18 '15 at 18:18
  • @MSU_Bulldog Fixing the height did reduce the buttons size but it made it the size of a pin and completely unclickable. I'd like to adjust the labels size as well. – Declan McKenna Nov 19 '15 at 13:10
  • I really can't give you any more information, why not go through some auto layout tutorials on setting constraints? I think after that you will be able to understand how to pin objects to other objects and get the result you are looking for. Here is a good one for iOS 9.1: http://www.raywenderlich.com/115440/auto-layout-tutorial-in-ios-9-part-1-getting-started-2 – MSU_Bulldog Nov 19 '15 at 15:14
  • No problem, thanks for the help. I've completed that tutorial, I'll just keep playing around with it till it fits. – Declan McKenna Nov 19 '15 at 15:48

1 Answers1

0

A combination of IB and programmed constraints did the job for me:

Community
  • 1
  • 1
Declan McKenna
  • 4,321
  • 6
  • 54
  • 72