Auto iOS layout does not work properly Xcode 8.2

Asked

Viewed 130 times

2

I’m developing an App in Xcode 8.x.

I have a problem resizing 4 buttons on the first screen. I work on the design of iPhone 5 or 6 and configure all auto layout, when I run in all Vices is cool except in Iphone 4 where I can open in ipad, but the buttons in the resize just go up, I wanted a hint on where I would be missing, I am using the auto layout as follows, right click and drag to the side and use the horizontal space etc. and successively.

see the images:
inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

  • 1

    Any chance you are using fixed height for the buttons and the screen is not tall enough to display all of them above each other at set height?

  • So I’ve always done the same way for Uiview, I’m guessing that’s right, I’m going to revisit that concept.

  • 1

    If that’s the problem, Voce can put the buttons in a stackview. Then she takes charge of distributing the buttons so that they fit on the screen

  • the best way I found it was, check the device, and I positioned and resized them in their place, it was the fastest gave right.

2 answers

1

Well, an alternative for you to present the last button on iPhone 4 is to use a Tableview with static cells :)

And in case your list of items increases, you will no longer have this problem this iPhone model.

inserir a descrição da imagem aqui

  • Thanks for the suggestion, I think it will be an alternative.I’ll see if I can do it this way. Thanks a lot.

  • If I’m not mistaken to use static cells, you must have a Tableviewcontroller (it can’t be a Viewcontroller with a Tableview inside). I don’t know if it’s viable in your project

0

Friend, it is difficult to give any hint from Autolayout... where there are several ways for you to arrive at a result.

An alternative would be you try to configure the layout from iPhone 4s, and let iOS and constraints adapt to the other Vices.

As follows: view as iphone 4s

once your layout "embedded" in the size of the iphone 4s, the rest will work.

As for the size of the buttons, try to use height based on the size of the screen... it is a bit "boring" but it is a very good solution. I have used several times. Just make for a button, and give an "Equal height" to the others.

Like this:

1 - Equals view height in question equals Superview view height altura da view igual a da superview

2 - Go to the Constraint you just created, and click edit: editar constraint de altura

3 - In the Multiplier attribute, you select the multiplier of this Constraint. The value works as a percentage. Being 0: zero percent; and 1: 100%. In my example I put 12% of the screen size, ie 0.12. editar atributo multiplicador

After that, you could leave the other button with the height equal to the button you just changed.

Anyway... that’s it. I hope it helps.

JLU.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.