I'm trying to reuse some of my view in my storyboard. I start with a uitabbarcontroller and have some views connected for each tab. Now i dropped a NEW uitabbarcontroller into the storyboard and I want to connect one of it's tabs to the SAME viewcontroller that is connected to the original tabbar.
Can you 'reuse' viewcontrollers in the storyboard like that? Or do you have to create new viewcontrollers? I assume the former works, as I'm able to do it else where in the storyboard by choosing 'push'. It's just not working with the uitabbar if I choose 'relationship'.
ok. I found the cause of my crash and I think I know what's going on. It appears that if I connect another uitabbarcontroller, then indices for the views on the first tabbar get screwed up. What I'm doing to getting references to the viewcontrollers in the uitabbar using
UINavigationController* ar_nav=[self.viewControllers objectAtIndex:1];
_artvc = [ar_nav.viewControllers objectAtIndex:0];
if (![_artvc isKindOfClass:[ArtistTableViewController class]])
{
TGLog(@"ERR wrong class! %@", [_artvc class]);
exit(0);
}
As soon as I connect the second uitabbar Turns out that index 1 isn't that class (even though the storyboard shows that it is).
using this code on my original tabbar controller
UINavigationController* n;
for (n in self.viewControllers)
{
UIViewController* vc=[n.viewControllers objectAtIndex:0];
TGLog(@"%@", [vc class]);
if ([vc isKindOfClass:[ArtistTableViewController class]])
{
_artvc = (ArtistTableViewController*)vc;
}
if ([vc isKindOfClass:[SongsTableViewController class]])
{
_stvc = (SongsTableViewController*)vc;
}
if ([vc isKindOfClass:[AlbumTableViewController class]])
{
_altvc = (AlbumTableViewController*)vc;
}
}
works fine until I connect the second uitabbar. Once I do that, my viewcontroller is gone from the loop.