Container UIViewController Not Releasing it's Child View Controllers

前端 未结 3 1664
旧时难觅i
旧时难觅i 2021-01-31 22:02

I have a custom container UIViewController that has six child UIViewControllers, and a set of tabs that the user interacts with to switch between the child view controllers. The

3条回答
  •  醉梦人生
    2021-01-31 22:13

    This is not the way to add and remove child view controllers

        [childViewController willMoveToParentViewController:nil];
        [childViewController view] removeFromSuperview];
        [childViewController removeFromParentViewController];
    

    is the way to remove and to add it is

        [parentViewController addChildViewController:childViewController];
        [parentViewController.view addSubview:childViewController.view];
        [childViewController didMoveToParentViewController:parentViewController];
    

提交回复
热议问题