我有我想检测,如果它是视图控制器2内摸了标签栏(I have a tab bar that I am

2019-10-17 21:15发布

基本上我有鉴于控制器的一个标签栏。 我想,如果这是tabaritem视图控制器2.什么是执行这一任务的最佳方法内触及检测? 我可以发布更具体的代码,如果你想。

视图控制器1

  TUHomeViewController *homeViewController = [[TUHomeViewController alloc] initWithNibName:nil bundle:nil];
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];

视图控制器2

Answer 1:

您应该使用UITabBarControllerDelegate。 请参阅: http://developer.apple.com/library/ios/#documentation/uikit/reference/UITabBarControllerDelegate_Protocol/Reference/Reference.html

更具体地讲,看

tabBarController:didSelectViewController:

“告诉用户在选项卡栏选择的项目的委托”。



Answer 2:

使用委托didselectviewcontroller,并把委托tabbarcobtroller的自我



文章来源: I have a tab bar that I am trying to detect if it was touched inside view controller 2