0

I created a TabBarController but their TabBarItems doesn't appears.

What am I doing wrong? Because Ive already added the tabBarItem of View Controllers, and they don't appears.

//Create Controllers
SBQNewsViewController *news=[[SBQNewsViewController alloc] initWithStyle:UITableViewStylePlain];
SBQFavoritesViewController *favs=[[SBQFavoritesViewController alloc] initWithStyle:UITableViewStylePlain];

//Create NavigationControllers
UINavigationController *newsNav=[[UINavigationController alloc] initWithRootViewController:news];
UINavigationController *favsNav=[[UINavigationController alloc] initWithRootViewController:favs];

//Create TabBarController
UITabBarController *tabReader=[[UITabBarController alloc] init];
tabReader.viewControllers=@[newsNav,favsNav];

self.window.rootViewController=tabReader;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;

Screen

And the tabBarItems added:

Into SBQNewsViewController:

#import "SBQNewsViewController.h"

   @implementation SBQNewsViewController

   - (id)initWithStyle:(UITableViewStyle)style
   {
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
        self.tabBarItem.image = [UIImage imageNamed:@"Reportslc.png"];
        self.tabBarItem.title = @"Noticias";
    }
    return self;
   }

Into SBQFavoritesViewController:

#import "SBQFavoritesViewController.h"

  @interface SBQFavoritesViewController ()

  @end

  static NSString *CellIdentifier=@"CellIdentifier";

  @implementation SBQFavoritesViewController

  - (id)initWithStyle:(UITableViewStyle)style
  {
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
        self.tabBarItem.image = [UIImage imageNamed:@"Favoritelc.png"];
        self.tabBarItem.title = @"Favoritos";
    }
    return self;
  }
santibernaldo
  • 825
  • 1
  • 11
  • 26

3 Answers3

0

You have not added tabBarItem title to your code.. USe tabBarItem.title and set some title to see your tab bars..

Dinesh
  • 929
  • 7
  • 25
0

I set the Items into didFinishLaunchingWithOptions and it works now

UITabBarItem *itemsNews=[tabReader.tabBar.items objectAtIndex:0];
    [itemsNews setTitle:@"Noticias"];

UITabBarItem *itemsFavs=[tabReader.tabBar.items objectAtIndex:1];
    [itemsFavs setTitle:@"Favoritos"];

Thanks Bhumeshwer katre!

santibernaldo
  • 825
  • 1
  • 11
  • 26
0

instead of setting the tabBarItem.title try setting the screentitle:

self.title = @"Favoritos";
thorb65
  • 2,696
  • 2
  • 27
  • 37