Anthony
Anthony

Reputation: 2801

Include an iOS Storyboard project into another one?

Me and other people work in the same project, but separately. Imagine that the first person creates a Storyboard project with a UITableViewController. The second one wants to include the previous element in his own Storyboard project. How can I connect these two Storyboard projects?

Thanks

Upvotes: 0

Views: 1292

Answers (1)

Anthony
Anthony

Reputation: 2801

I have one solution: simply create a property or variable as appropriate. For example:

    @property (strong, nonatomic) UIStoryboard * storyboard1;
    @property (strong, nonatomic) UIStoryboard * storyboard2;

    .....

    .m
    -(void)initMyStoryboards{
       storyboard1 = [UIStoryboard storyboardWithName:@"storyboard1" bundle:nil];
       storyboard2 = [UIStoryboard storyboardWithName:@"storyboard2" bundle:nil];
    }

    -(void)launchViewFromS1{
         //use view in storyboard1
         MyViewController1 *myViewController = [self.storyboard1 instantiateViewControllerWithIdentifier:@"MainView"];
         ....
    }

    -(void)launchViewFromS2{
        //use view in storyboard2
        MyViewController2 *myViewController2 = [self.storyboard2 instantiateViewControllerWithIdentifier:@"OtherView"];
        ....
    }

other exemple:

-(void)launchMyView{
    UIStoryboard * storyboard = [UIStoryboard storyboardWithName:@"storyboard1" bundle:nil];
    ViewController1 *myViewController =[storyboard instantiateViewControllerWithIdentifier:@"MainView"];
    ....
}

Upvotes: 1

Related Questions