a Custom Segue that Simulates a Push Segue turns VC into Zombie

后端 未结 3 2039
粉色の甜心
粉色の甜心 2021-02-10 19:17

[To Make things short and clear]

I\'ve written a custom segue.

-(void)perform {
UIView *preV = ((UIViewController *)self.sourceViewController).view;
UI         


        
3条回答
  •  闹比i
    闹比i (楼主)
    2021-02-10 19:30

    You need to keep a reference to destinationViewController so that it doesn't get deallocated. Obviously, you cannot do this in your custom segue as this object is freed after the transition has finished. The standard push segue does this by adding the view controller to the viewControllers property of a UITabBarController, for example.

    In your case, you could call

    [sourceViewController addChildViewController:destinationViewController];
    

    to establish a proper connection between the view controllers. Don't forget to call removeFromParentViewController in your reverse segue.

提交回复
热议问题