2013-03-19 91 views
-1

我在視圖控制器1中添加了這個標籤欄,它完美地工作,唯一的問題是我希望它執行以下功能[self.navigationController popViewControllerAnimated:YES];,但在視圖控制器2中當標籤欄按鈕被觸摸時。最好的行動是什麼?標籤欄方法

UINavigationController *homeNavigationController = [[UINavigationController alloc] initWithRootViewController:homeViewController]; 
homeNavigationController.tabBarItem = [[DSTabBarItem alloc] initWithFinishedSelectedImage:[UIImage imageNamed:@"home"] 
                  finishedUnselectedImage:[UIImage imageNamed:@"home1"] 
                       iconSize:CGSizeMake(76, 59) 
                       tag:0]; 
[tabBarViewControllers addObject:homeNavigationController]; 
+0

什麼是你需要什麼呢? – 2013-03-19 04:19:58

回答

0

如果以編程方式添加了tabbarcontroller。並在該類中添加以下方法。 然後你的導航控制器將更改爲根視圖。而且你可以把你自己放在如果你的要求之間。

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController 
{ 
    if ([self.tabBarController.selectedViewController isKindOfClass:[UINavigationController class]]) 
    { 
     [(UINavigationController*)self.tabBarController.selectedViewController popToRootViewControllerAnimated:YES]; 


    } 

} 
0
DetailSettingsViewController *settings = [[DetailSettingsViewController alloc] initWithNibName:@"DetailSettingsViewController" bundle:nil]; 

[self.navigationController pushViewController:settings animated:YES];