iosxcodeuiimageviewconstraints

Xcode 6.4 - Unable to set constraints on Views or ... anything


There are many guides out there that talk about auto-layout such as: http://www.raywenderlich.com/83129/beginning-auto-layout-tutorial-swift-part-1

Now constraints don't seem to be super complicated except that when it comes to trying to set them on a UIImageView within a ViewController, With "Use Auto-Layout" ticked, I can't for the life of me set any constraints as when I click any of the three buttons used to achieve this, all the options for setting constraints is greyed out.

I'm sure this is something simple... little help?

I've found something in reference materials: "Constraint options that require multiple elements are disabled if you have only a single element selected." but in none of the guides do I have to have more than the UIImageView selected to set constraints.

Edit: added images:

ContraintsGreyedOut1of2

ContraintsGreyedOut2of2


Solution

  • This is because you remove root view from view controller. When you add UIViewController to storyboard you can see this:

    enter image description here

    If you delete this view and add UIImageView you see this:

    enter image description here

    enter image description here

    So add UIView as root and UIImageView as single subview of root view. And then you can play with constraints:

    enter image description here