Reputation: 17
so I'm trying to get familiar with iOS programming and while trying to mess with auto layout, I seem to have run into a problem. As soon as I try to add a size constraint to one of the black squares on my storyboard, it goes to the top left corner. Does anyone know of a way to fix this?
Upvotes: 0
Views: 67
Reputation: 23
First of all clear the constraint of the view that is misplaced after applying your constraints. In your case you could also add constraints of Top and Bottom edges with the left bottom corner box. After that you could apply trailing edges between bottom right and top right box or add 0 constraint to your bottom right box with superview. That should fix your issue.
Upvotes: 0
Reputation: 5088
i suggest reading about auto layout here
when it comes to layout and positions in iOS you need to have the constraint components well defined, for instance, if a view inside a viewcontroller can have ( leading, trailing ) those are X components , and (spacing to top safe area, or bot safe area) those are the Y components. a miss defined constraints gives bugs on the UI, so if your View is up to the corner on Y axes check if u are missing one there, and so on think about constraints as rules to tell the application where to layout those views. as (is giving it only Y's enough for it to understand) ofc not, and so on check out whats missing and what conflicts can have between other constraints that belongs to other views
Upvotes: 1