我UITabbarController
在我的应用程序中使用过。其中一个 tabBarItemcontactsViewController
显示联系人列表UITableView
。当我单击 tableRow 时,它会加载另一个视图。然后我单击其他一些。再次单击tabBarItem
它contactsViewController
会将我带到我离开的视图。它不显示默认联系人视图UITabbarController
。我已经以编程方式创建。如何在点击时显示默认 tabBarView tabBarItem
?
tabbarController = [[UITabBarController alloc]init];
self.tabbarController.delegate = self;
tabbarView = [[UIView alloc]initWithFrame:CGRectMake(0, 431, 320, 49)];
UIImageView *tabImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 49)];
[tabImage setImage:[UIImage imageNamed:@"Taskbar.png"]];
[tabbarView addSubview:tabImage];
UIButton *tabItem1 = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 64, 49)];
[tabItem1 setImage:[UIImage imageNamed:@"Btn_Home.png"] forState:UIControlStateNormal];
[tabItem1 setTag:1];
[tabItem1 addTarget:self action:@selector(tabBarBtnAction:) forControlEvents:UIControlEventTouchUpInside];
[tabbarView addSubview:tabItem1];
-(IBAction)tabBarBtnAction:(id)sender
{
UIButton *btn = (UIButton *)sender;
// NSLog(@"tag %d\n",btn.tag);
[self resetTabBarBtnImage];
[self resetAllTabBarBtnImage];
PreviousBtnTag = btn.tag;
if ([btn tag]==1) {
tabbarView.hidden = YES;
[self.tabbarController setSelectedIndex:0];
[self.navigationController popToRootViewControllerAnimated:YES];
[btn setImage:[UIImage imageNamed:@"Btn_Home-Over.png"] forState:UIControlStateNormal];
}
else if([btn tag]==2)
{
tabbarView.hidden = NO;
[self.tabbarController setSelectedIndex:1];
[btn setImage:[UIImage imageNamed:@"Btn_Contacts-Over.png"] forState:UIControlStateNormal];
[self.navigationController popToRootViewControllerAnimated:YES];
}