I have setup a simple layout with a button which, when pressed, causes the storyboard subview to load a xib file and assigns its view to the storyboard subview. The problem is that the xib view causes the storyboard subview to 'break' its original constraints:
Here's the main storyboard (left) and xib view (right):
Here's what happens when I press the button on the main storyboard.
- (IBAction)btnShowView:(id)sender {
xibViewController *xib_VC = [[xibViewController alloc] initWithNibName:nil bundle:nil];
xib_VC.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;
//xib_VC.view.frame.size = self.myView.frame.size;
UIView *view = xib_VC.view;
[self.myView addSubview:view];
}
And here's the result - you can see that the xib view has caused the main storyboard subview to go outside of its constraints.
I'm guessing that dynamically changing the storyboard subview overwrites its original view and constraints? Do I have to programatically add these constraints again before assigning the xib view to the storyboard subview?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…