Create a tab bar first:-
UitabBarController *tabBars;
tabBars= [[UITabBarController alloc] init];
This View Controller will show a tab bar with two items and navigation to different pages:-
ViewController1 *mjCat=[[ViewController1 alloc]initWithNibName:@"ViewController1" bundle:nil];
UINavigationController *Browsing1=[[UINavigationController alloc]initWithRootViewController:mjCat];
mjCat.tabBarItem.title=@"Browse";
mjCat.tabBarItem.tag=1;
mjCat.tabBarItem.image=[UIImage imageNamed:@"browse.ico"];
ViewController2 *exCat=[[ViewController2 alloc]initWithNibName:@"ViewController2" bundle:nil];
UINavigationController *Browsing2=[[UINavigationController alloc]initWithRootViewController:exCat];
exCat.tabBarItem.title=@"Explore";
exCat.tabBarItem.tag=2;
exCat.tabBarItem.image=[UIImage imageNamed:@"explore.ico"];
[tabBars setViewControllers:[NSArray arrayWithObjects:majorBrowsing,exploreBrowsing, nil]];
[self.navigationController pushViewController:tabBars animated:YES];
No comments:
Post a Comment