Segue to another storyboard?

后端 未结 6 2014
暗喜
暗喜 2020-11-27 09:04

Is it possible to segue from one storyboard to another, or to embed a storyboard in a view controller in another storyboard? I need to place a UITabBarController

6条回答
  •  伪装坚强ぢ
    2020-11-27 09:31

    Yes, but you have to do it programmatically:

    // Get the storyboard named secondStoryBoard from the main bundle:
    UIStoryboard *secondStoryBoard = [UIStoryboard storyboardWithName:@"secondStoryBoard" bundle:nil];
    
    // Load the initial view controller from the storyboard.
    // Set this by selecting 'Is Initial View Controller' on the appropriate view controller in the storyboard.
    UIViewController *theInitialViewController = [secondStoryBoard instantiateInitialViewController];
    //
    // **OR**  
    //
    // Load the view controller with the identifier string myTabBar
    // Change UIViewController to the appropriate class
    UIViewController *theTabBar = (UIViewController *)[secondStoryBoard instantiateViewControllerWithIdentifier:@"myTabBar"];
    
    // Then push the new view controller in the usual way:
    [self.navigationController pushViewController:theTabBar animated:YES];
    

提交回复
热议问题