How to change the selected index of the tabbar
In my app there is a tab bar. On one of the elements of the tabbar (say element at index 1 of the tabbar) there are some buttons on clicking them will guide to some pages which are under some other element of the tabbar(say element 开发者_Python百科at index 3 of the tabbar).
I was able to navigate to the required page but the tabbar selection is not properly displayed. Even though the page is in 3rd tab bar element, the 1st element is selected.
How to solve this? Ideas plz
Finally I got the solution.
Before going into the answer let me tell u one thing, i think all the problem occured because the tab bar was implemeented via code. If it was done through nib then the problem won't come .
I solved this problem in the following manner:
Instead of pushing the required view controller's object using self.navigationcontoller i typecasted the tabbar's required view.
Please check the code also
TabViewController *tabBarController = [[TabViewController alloc]
initWithNibName:GENERIC_TAB_NIB
bundle:nil];
DetailsViewController *detailsVC = [[DetailsViewController alloc] initWithNibName:DETAILS_NIB
bundle:nil];
UINavigationController *navigationController = (UINavigationController *)[tabBarController.viewControllers objectAtIndex:1];
[navigationController pushViewController:detailsVC animated:YES];
[detailsVC release];
精彩评论