in an ios application, I have a custom UITableViewCell with a lot of views in it. I am using auto layout and setup all the constraints as I need.
But now I need to have a main view (in the content view) and put all the other views in it (some sort of a parent view to all).
This is an example of how my cell looks in the interface builder:
it has all the views setup with the constraints.
I know there is an xcode feature to embed selected views inside a parent view:
So I select all the view and select to embed them in a view. I get the following:
My Problem
Although the views are embedded correctly in a superview, the autolayout constraint were removed, and now I have to recreate them.
Is there a way I can put all the views inside a superview and have the same autolayout constraints without having to recreate them all? Thank you
As mentioned in the comments above, this approach works well for me:
indiestack.com/2013/12/transplanting-constraints
In short, the approach is:
<constraints></constraints>
and <subviews></subviews>
tags<constraints></constraints>
and <subviews></subviews>
tags with the copied content<constraints></constraints>
you pasted in.Caveat: This will break any outlets to constraints you may have set up. Outlets to other things, views, etc... will be fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With