Constraints trouble

Hi. I have a really big trouble with the constraints. My constraints not work at all. I'll tell you in an easier way. I have the A object on the top of view controller and its x postion is center. Another object, B object is lower and is also center of x position. Then I have two buttons lower than the B object. Both the buttons have same y position but different x positions. Under the two buttons, there is another button on the left of the view controller. Confused? If yes, please tell me, I will try to give you the picture. If no, can anyone help me, please? Thanks everyone

Replies

Clear and pretty usual. What is the problem you have ?


If it is constraint creation, you can simply position the objects in the view and then ask for

'Editor -> Resolve Auto Layout Issues -> Clear constraints'

then

'Editor -> Resolve Auto Layout Issues -> Add Missing constraints'

Thank you. It worked fine, but there is a little trouble with the size of the objects.

You can also set constraints for the size of objects : look in dimension inspector what are the constraints which were created and adpat them if needed.


Don't forget to mark the thread as closed (correct answer) when your problem is solved. Wish you good development.

Can you please tell me where is the dimension inspector? Thanks

Hello? Anyone please help?

Claude will have meant the size inspector which is located in the utilities area on the right-hand side of an Xcode window.

The size inspector you meant is the one that has the width, height, aspect ratio, right? If it is, how can I use it to set the size so that the size of the object will look good after 'Editor -> Resolve Auto Layout Issues -> Add Missing constraints'. Thanks

You have 2 ways to do this :

- look in size inspector : you should see some size constraints if they have been defined automatically : içn the constraints area, see Width or height ; to change it, double click on the constraint cell, then change the values as you want

- if you want to add a size constraint yoursel, select the object in IB ; then, at the bottom of the IB panel, click on the 3rd icon, named Pin (symbol is a square between 2 vertical bars). Set the width and height as you want.

Sorry for asking so many questions (this is my first time to set the constraints). But which icon should I click to see the constraaint area? I clicked the 2nd and I don't see width or height? Also, what values should I set for the width and height so that the object size will be right in every device? Thanks

My problem is after I set the constraints, and run on iPhone, some object is hidden behind another object. Some object size becomes too "tall" but too "thin".

Now, the size is quite alright but I met a more complicated problem. It's about the the position. For example, I put some objects straight in a line. but when it run, some going to the left, some going to the right, some remain. Anyone knows how to fix this?

In inspector panel, the icon for size is the 5th on top of inspector panel. Once you are here and you have selected the object, you see all the constraints that relate to the object. Double click on it to open a new panel where to set values.

In the xib window, the icon is the 4th at the very bottom ; in XCode8, it is named "add new constraints" (symbol is a square between 2 vertical bars). You click here after selecting the object in the nib ; you will find here the width and height.

In order to help you, could you popst here the list of objects that are ill aligned. And post all the constraints of these objects

OK. 3 images too 'tall', 2 images disappear. I lined this 5 images horizontally. 2 labels that written '0' dissapeared. I have 5 labels which written "0" and the labels are placed under the five images. One of the label dissapeared half. I lined another 5 labels vertically, the labels which written "50" became "5", the labels which written "30" became"3" the label which is placed in the end of the line is hidden behind an image (Actually, I put some images beside the labels which written "50" or "30")

Clearly you have a width constraint issue.


But to help, it would be useful to see exactly the constraints you have defined and how.