In my app I am attempting to switch views which each is their own XIB while using custom animations to do so. I made a base view controller as a parent view to hold all the code but I just can't seem to get this to work.
I made an IBOutlet for all of the view controllers in my app and in interface builder, I connect the outlets to the proper controller. Each controller loads the proper XIB too so none of that is the issue. The issue is the following changing views 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?
Thanks!