Take the 2-minute tour ×

I have a plist that populates everything on the tab bar including the tableview: tab name, tab icon, title, detail, and makes the VCs into viewControllers array. "Banner VC alloc with content view controller : viewControllers" - wont accept an array, only a single VC, or multiple VCs if theyre known. The tabs are mutable, they can move and change, so I cant program them individually. How do I pass an unknown array of tabs to a bannerview controller?

Below is very close, but banner vc will only display the last set in the plist, not the whole set...And will just crash if I try passing viewControllers array to it.

What im asking is... How do you load banner vc with one plist that has 5 tabs built in it?

Thanks ahead of time. And if im way off course could someone please attempt to stear me. I really dont want to limit myself to onyl 5 tabs.

I just add a key to the plist and it automaticlly ads a tab to the more section... How do I pass this through bannew VC?

_tabBarController.viewControllers = viewControllers; //Loads the array viewControllers fine with 5 tabs and icons, but no banner container

_tabBarController.viewControllers = @[[[BannerViewController alloc] initWithContentViewController:viewControllers]] // Crashes on launch

_tabBarController.viewControllers = @[[[BannerViewController alloc] initWithContentViewController:newsNavigationController]] // Loads only the last key in plist and with no icons

     @implementation AppDelegate {
    UITabBarController *_tabBarController;

    CGRect bounds = [[UIScreen mainScreen] bounds];
    self.window = [[UIWindow alloc] initWithFrame:bounds];
    self.window.backgroundColor = [UIColor whiteColor];    

    NSMutableArray * viewControllers = [[NSMutableArray alloc] init];

    NSString * subscriptionListFile = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"My_Subscription.plist"];
    NSDictionary * subscriptionList = [[NSDictionary alloc] initWithContentsOfFile:subscriptionListFile];
    NSArray * subscriptionFolders = subscriptionList[@"Folders"];

    NewsListViewController * newsController = nil;
    UINavigationController * newsNavigationController = nil;

    for (NSDictionary * folderDetails in subscriptionFolders) {

        NSArray * newsItems = folderDetails[@"Items"];
        NSString * folderTitle = folderDetails[@"FolderName"];
        NSString * folderIcon = folderDetails[@"FolderIcon"];
        UIImage * folderIconImage = [UIImage imageNamed:folderIcon];

        newsController = [[NewsListViewController alloc] initWithNewsSourceList:newsItems];
        [newsController setTitle:folderTitle];
        newsNavigationController = [[UINavigationController alloc] initWithRootViewController:newsController];
        [newsNavigationController setTitle:folderTitle];
        [newsNavigationController.tabBarItem setImage:folderIconImage];
        [viewControllers addObject:newsNavigationController];


    _tabBarController = [[UITabBarController alloc] init];

//  _tabBarController.viewControllers = viewControllers;   <--- this line works, below doesnt load the array...

    _tabBarController.viewControllers = @[[[BannerViewController alloc] initWithContentViewController:viewControllers]]

         self.window.rootViewController = _tabBarController;
        [self.window makeKeyAndVisible];
        return YES;
@end        //The above crashes, but works fine if I SKIP "BannerViewController alloc..." 
            //and go right to "_tabBarController.viewControllers = viewControllers"  

            //perfect but no adbanner :(
share|improve this question
What class is BannerViewController a subclass of? –  rdelmar Nov 8 '12 at 18:44
Its straight from iAd suite oct24th, the tabbed banner example. its just a uivc. –  Joshua Piper Nov 8 '12 at 23:45

1 Answer 1

up vote 0 down vote accepted

The method, initWithContentViewController:, as you can tell from its name (controller not controllers), accepts only one view controller as its argument. It's not quite clear what you're trying to do, since that method is a method of UIPopoverController, and you wouldn't normally make a popover controller one of the controllers in a tabBar controller's viewControllers.

share|improve this answer
Im trying to load a tab bar into iAd container vc. The for loop creates the tabs and ads them to viewControllers, then its set to tabbar controllers. What I cant do is load an array into bannerVC alloc, I can't do them individually like "banner vc alloc vc1, vc2, vc3" - because I dont know the number of tabs to start with. It works the way its written if i skip bannerVC. Or maybe im just way in over my head... –  Joshua Piper Nov 8 '12 at 23:34
_tabBarController = [[UITabBarController alloc] init]; _tabBarController.viewControllers = @[ [[BannerViewController alloc] initWithContentViewController:originalIpsumViewController], [[BannerViewController alloc] initWithContentViewController:meatyIpsumViewController], [[BannerViewController alloc] initWithContentViewController:veganIpsumViewController], ]; That is apples example, but I have a for loop, not a defined number of VCs –  Joshua Piper Nov 8 '12 at 23:47
Maybe Im just having a brain fart, maybe if i put it in the for loop somehow... –  Joshua Piper Nov 8 '12 at 23:50
@JoshuaPiper, sure, you could add them like in Apple's example, but in a loop, you just need to create one BannerViewController with its content view controller in each pass through the loop. –  rdelmar Nov 9 '12 at 0:52
I understand the concept but im a noob working off a template. I cant make tab bar.viewcontrollers = bannervc in a for loop, so how do I add to tabbar? It very simple im sure i just am struggling... –  Joshua Piper Nov 9 '12 at 1:46

Your Answer


