Reputation: 175
I try this but it not works I can not see tab bar item..How can I solve this problem? Thanks for your help.
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
myTabBarController = [[UITabBarController alloc] init];
tab1 = [[ZiyaretFormTab1 alloc] initWithNibName:@"ZiyaretFormTab1" bundle:nil];
tab2 = [[ZiyaretFormTab2 alloc] initWithNibName:@"ZiyaretFormTab2" bundle:nil];
tab3 = [[ZiyaretFormTab3 alloc] initWithNibName:@"ZiyaretFormTab3" bundle:nil];
tab4 = [[ZiyaretFormTab4 alloc] initWithNibName:@"ZiyaretFormTab4" bundle:nil];
tab5 = [[ZiyaretFormTab5 alloc] initWithNibName:@"ZiyaretFormTab5" bundle:nil];
myTabBarController.viewControllers = [NSArray arrayWithObjects: tab1, tab2,tab3,tab4,tab5,nil];
UITabBarItem *tabItem = [[[myTabBarController tabBar] items] objectAtIndex:1];
[tabItem setTitle:@"theTitle"];
[self.view addSubview:myTabBarController.view];
myTabBarController.selectedIndex=0;
}
Upvotes: 2
Views: 5684
Reputation: 1558
UITabBarItem *item = [self.tabBarController.tabBar.items objectAtIndex:0];
[item setTitle:@"fgfdgd"];
Upvotes: 0
Reputation: 1028
Have you tried to set
[tab1 setTitle:@"Your Title"]
after allocating and initialising it.
Upvotes: 0
Reputation: 143
Put the tab settings to AppDelegate.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Put your name and icon information uniforms visit here:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = @"Kulağını tersten tutmana gerek yok";
self.tabBarItem.image = [UIImage imageNamed:@"ringtab.png"];
}
return self;
}
Upvotes: 0
Reputation: 40995
Tab bar titles are controlled by their respective view controllers. The easiest way to set the title is from within the view controller for that tab, instead of trying to set it in the tab directly.
Each view controller has a title
property which is used to set the title in tab bars and navigation bars. It also has a tabBarItem
property which has it's own title
property that you can set if you want to just set the tab and not affect navigation bars.
So in the viewDidLoad of your viewController, you could write:
self.tabBarItem.title = @"theTitle";
Upvotes: 0
Reputation: 11970
In each of your view controllers that go into the tabs (ZiyaretFormTab1 to ZiyaretFormTab5), insert this code into initWithNib or viewDidLoad functions.
UITabBarItem * tabtitle = [[UITabBarItem alloc] initWithTitle: @"title"
image: nil //or your icon
tag: 0];
[self setTabBarItem: tabtitle];
Upvotes: 2