In my application, I am trying to switch views, each of which is their own XIB when using custom animations. I made the base view controller as the parent view to store all the code, but I just can't get it to work.
I made an IBOutlet for all view controllers in my application and in the interface builder, I connect the sockets to the correct controller. Each controller loads the corresponding XIB, so none of them is a problem. The problem is the following change to the view code.
This is my code:
-(void)changeViews {
CGRect frame = self.view.frame;
frame.origin.x = CGRectGetMaxX(frame);
theView4.view.frame = frame;
[self.view addSubview:theView4.view];
[self addChildViewController:theView4];
[self transitionFromViewController:theView1
toViewController:theView4
duration:1
options:UIViewAnimationOptionTransitionNone
animations: ^{
CGRect frame = self.view.frame;
theView4.view.frame = frame;
frame.origin.x -= frame.size.width;
self.view.frame = frame;
}
completion:completion:nil];
And this is the console crash:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Children view controllers <MyGameViewController: 0x1dd25210> and <Settings: 0x1dd249d0> must have a common parent view controller when calling -[UIViewController transitionFromViewController:toViewController:duration:options:animations:completion:]'
Does anyone know how to fix this?
Thank!