Friday, 9 August 2013

How to add UIBarbuttonitem different on navigationbar in each tabbar item iOS

How to add UIBarbuttonitem different on navigationbar in each tabbar item iOS

I push Viewcontroller (viewcontroller 1) that including uitabbarcontroller
has 3 viewcontroller (tabitem 1, tabitem 2, tabitem 3) .Now i want in each
tabbaritem has different UIBarbuttonitem on uinavigationBar. Exm: in
tabitem 1 hass "1" barbuttonitem , in tabitem 2 has "2" barbuttonitem, in
tabitem 3 has no barbuttonitem. How can i do it?
this is my code to created UItabbarcontroller:
- (void)viewDidLoad
{
[super viewDidLoad];
// loginview = [[LoginTab alloc] init];
// Do any additional setup after loading the view from its nib.
self.tab=[[UITabBarController alloc]init];
CGRect screenBounds = [[UIScreen mainScreen] bounds];
if (screenBounds.size.height == 568)
{
// code for 4-inch screen
// LoginButton.frame = CGRectMake(0, 518, 80, 49);
self.tab.view.frame = CGRectMake(0,0,320,568);
}
else if (screenBounds.size.height == 1024)
{
//code for ipad
}
else if (screenBounds.size.height == 480)
{
// code for 3.5-inch screen
// LoginButton.frame = CGRectMake(0, 430, 80, 49);
self.tab.view.frame = CGRectMake(0,0,320,480);
}
// FirstViewController
UploadTab *uploadview=[[UploadTab alloc]initWithNibName:nil bundle:nil];
uploadview.title=@"Uploading";
uploadview.tabBarItem.image=[UIImage imageNamed:@"Uploading.png"];
//SecondViewController
ConvertTab *convertView=[[ConvertTab alloc]initWithNibName:nil
bundle:nil];
convertView.title=@"Convert";
convertView.tabBarItem.image=[UIImage imageNamed:@"Convert.png"];
//ThirdViewController
CompletedTab *completedView=[[CompletedTab alloc]initWithNibName:nil
bundle:nil];
completedView.title=@"Completed";
completedView.tabBarItem.image=[UIImage imageNamed:@"Completed.png"];
self.tab.viewControllers=[NSArray
arrayWithObjects:uploadview,convertView, completedView, nil];
[self.view addSubview:self.tab.view];
//[self presentModalViewController:self.tab animated:NO]; // if use
it, tabbar at bottom of screen correctly
}
Also, I use above code, tabbar is show position not correct, it not at
bottom of screen. Pls give me any ideas? Thanks much

No comments:

Post a Comment