Sharing the Same UIViewController as the rootViewController with Two UINavigationControllers

前端 未结 3 1860
离开以前
离开以前 2021-02-02 17:13

Update: I have decided to go a different route with my problem. Instead of trying to reuse the same UIViewController directly, I use two vanill

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-02 17:15

    I think the easiest solution is to set no root view controller for your nav controller in the storyboard and then do something like this with your nav controller:

    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        UIViewController *topVC = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:@"myTopVC"];
        [self pushViewController:topVC animated:NO];
    }
    

    The first-pushed VC becomes the root.

提交回复
热议问题