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?
Asked
Active
Viewed 81 times
0

Pablo
- 28,133
- 34
- 125
- 215
1 Answers
1
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
}
}

David Berry
- 40,941
- 12
- 84
- 95
-
hey David. What if I want to access view controller which is embedded into reusable one?(black VC). Somehow on the picture I marked wrong VC that is reusable. – Pablo Mar 19 '14 at 18:53
-
1My recommendation would be "don't do that" Put the main interface for that switchable functionality in the view that's actually marked ReusavleViewController and have it forward the calls in it's own prepareForSegue to load the embedded view controller. – David Berry Mar 19 '14 at 19:27