Custom initializer for reusable view controller

85 Views Asked by At

As you can see from screenshot below, I have view controller, which I am reusing. Depending which tab bar is selected, different view controller instances are created. But depending on tab bar, I would like to initialize my view controller differently, before viewDidLoad. How can I achieve that?

enter image description here

1

There are 1 best solutions below

2
David Berry On BEST ANSWER

Do it in the prepareForSegue in the container view controller after making sure that your segue's are all named.

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if([segue.identifier isEqualToString:@"embedded"])
    {
        ReusableViewController* vc = (ReusableViewController*)segue.destinationViewController;
        // setup vc customization here
    }
}