Search code examples
iosswift3xcode8ios10

Connect StoryBoard Button with Programmatically build UITabBarController


i build two project

  1. Story Board -> Login Screen
  2. Programmatically -> UITabBarController

both are different Projects but managed With MVC structure now i want to connect StoryBoard Button with Programmatically build UITabBarController Please Help me to solve this Problem.


Solution

  • To create a view controller:

    UIViewController * vc = [[UIViewController alloc] init];
    

    To call a view controller (must be called from within another viewcontroller):

    [self presentViewController:vc animated:YES completion:nil];
    

    For one, use nil rather than null.

    Loading a view controller from the storyboard:

    NSString * storyboardName = @"MainStoryboard"; 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil];
    UIViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"IDENTIFIER_OF_YOUR_VIEWCONTROLLER"];
    [self presentViewController:vc animated:YES completion:nil];
    

    Identifier of your view controller is either equal to the class name of your view controller, or a Storyboard ID that you can assign in the identity inspector of your storyboard.