Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 5 Autolayout and making UIView's width equal to height

I am using autolayout. I have a UIImageView in IB. I want to make the its width equal to its height.

I learned how to do most of this stuff in Xcode 4. I know how to do it programically, but that produces and error that Apple hasn't fixed yet:

'Auto Layout still required after executing -layoutSubviews. UITableViewCell's implementation of -layoutSubviews needs to call super.'

So how do I set the this constraint in Xcode 5 Interface Builder?

like image 733
Padin215 Avatar asked Dec 16 '22 04:12

Padin215


1 Answers

As Timothy Moose commented, you have the option to keep aspect ratio in Xcode 5.1.

Make sure you have width and height the same. Add the aspect ratio constraint by using control drag to itself.

enter image description here

It will automatically ensure both height and width are maintained.

like image 85
Raj iOS Avatar answered Apr 02 '23 17:04

Raj iOS