Move all subviews to container view keeping positions and constraints
I’m using Xcode 5 and autolayout in my project. I have a
.xib file with a lot of subviews and constraints between them. Now I need to create an intermediate fullscreen container view and put all subviews there. So now I have
view->subviews, and I want
view->container view->subviews. When I do this in IB by dragging subviews into container view, they all get centred and all constraints get lost. It’s going to be a little hard to restore all constraints manually. Is there a smart way to do this keeping all subviews’ positions and constraints?
2 Solutions Collect From Internet About “Move all subviews to container view keeping positions and constraints”
Add your container view to the hierarchy (to get an object ID) in Interface Builder and close the view. Edit the
.xib file manually, in a text editor, and move all subviews to be under the container view. Constraints are created in IB with references to IB object IDs, so you will have to replace the constraints from referencing the superview with the container; a quick replace run should be sufficient.
You can do this in XCode 6 by using cut&paste to a separate view (which you can later drag around to wherever you actually need it).
- Remove app temporarily from Apple app store
- ios swift 3 – UIAlertController width
- Dailymotion embedded player on iOS devices (HTML5)
- Carthage and GoogleMap
- iOS:Add view below navigation bar across viewControllers
- Swift 2: Invalid conversion from throwing function of type to non-throwing function
- UIBezierPath appending overlapping isn't filled
- Draw NSTableView Alternating Rows Like iTunes 11
- xcode swift indexing forever
- OCUnit tests to existing iOS project. “ld: file not found”
- iOS swift NSMutableData has no member appendString
- Is it possible to combine multiple pdf files into a single pdf file programmatically in iphone?
- Can I use AVFoundation to stream downloaded video frames into an OpenGL ES texture?
- Dismissing of UIImagePickerController dismisses presenting view controller also
- In a UITableView, best method to cancel GCD operations for cells that have gone off screen?