0
votes

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.

2
i'm going to recreate a better question with a blank project.roocell

2 Answers

0
votes

That is definitely possible. Are you sure that the connection being made is to the view?

I apologize; that was unclear. When you are holding control and dragging the blue connection line, make sure you are connecting to the view itself (not anything else).

You should be able to create that relationship between the UITabBarController and the view, even if it is being shared by another UITabBarController.

What does it show you as your options when you try?

0
votes

ok. it has something to do (possibly) with the fact that I'm doing UITabbar->navcontroller->uitableview

When I add my second tabbar and create it's own navcontroller and connect it. Then 'reuse' the original tableview by connecting from the navcontroller to the tableview. THis doesn't seem to screw up the original tabbar.

here's a screenshot of my storyboard http://www.thumbgenius.dynalias.com/tabbar_vc_reuse.png