Reputation: 2862
I have been using Auto Layout programaticaly, but now I want to see what the storyboard feature in Xcode is all about. I think I have created my constraints for the first button (the button on the bottom left) correctly:
I don't seem to have any conflicting or ambiguous constraints, however when I run the app on my phone to test, it looks like this:
As you can see, the button is in the top left...and no matter what constraints I try to use, the button always sticks to the top left. I want it to be in the bottom left hand corner.
Any help would be appreciated, thanks.
UPDATE
I've tried the suggestions and neither have worked...here is how I have it setup now - I had to do left:-16 top:0 right:-16 bottom:0 to get the mapView constraints to work. For the button I used the insets option (as posted in an answer) and did bottom:0, left:0 - so as to pin it to the bottom left corner (only two constraints neccessary?):
Upvotes: 0
Views: 3498
Reputation: 3494
In your screenshot, the mapView seems to be some sort of custom class not the MKMapView
you can drag from the Interface Builder.
I just tried it and if you would have the normal MKMapView
, you would not be able to add subviews to the map. This is the setup I tried and all works as it is supposed to.
My suggestion would be to move the buttons not the same level as the mapView (so that they have the same superView
). Then you add your constraints and all should work just fine.
I think that the mapView has it's own way of handling subviews so maybe it just clears the constraints you add in the storyboard.
Let me know how it went! Good luck
Upvotes: 0
Reputation: 3484
Clear all contrains and:
1) pin MapView: 0 - 0 - 0 - 0 from Super View 2) pin button: 0(left) - 0 (bottom) from MapView 3) add width and heigth contraint
It should works
Upvotes: 1