Well I finally was able to make it work . Let me concisely explain the question again
->ContainerViewController
presents MainViewController
and when you check MainViewController.ParentController, it is infact ContainerViewController
->ContainerViewController
transitions from MainViewController
to SettingsViewController
using the following function
(void) showViewControllerWithName:(NSString*)vctype
{
UIViewController * toVC = [ViewControllerFactory getViewControllerOfType:vctype];
toVC.view.frame = containerView.bounds;
toVC.view.autoresizingMask = containerView.autoresizingMask;
[currentSubViewController willMoveToParentViewController:nil];
[self addChildViewController:toVC];
[self transitionFromViewController:currentSubViewController
toViewController:toVC duration:1.0 options:UIViewAnimationOptionCurveLinear animations:^{} completion:^(BOOL finished){
[currentSubViewController removeFromParentViewController];
[toVC didMoveToParentViewController:self];
}];
currentSubViewController = toVC;
}
->After the transition SettingsViewController.parentViewController
is nil
Following is the fix :
animations:^{} completion:^(BOOL finished){
[currentSubViewController removeFromParentViewController];
[toVC didMoveToParentViewController:self];
}];
currentSubViewController = toVC;
is changed to
animations:^{} completion:^(BOOL finished){
}];
[currentSubViewController removeFromParentViewController];
[toVC didMoveToParentViewController:self];
currentSubViewController = toVC;
And now SettingsViewController
has a parent.
Well, If anyone could explain what exactly is going on then it would be great.