问题描述
基本上我在视图控制器一中有一个标签栏.我正在尝试检测是否在视图控制器 2 内触摸了此 tabaritem.执行此类任务的最佳方法是什么?如果您愿意,我可以发布更具体的代码.
Basically I have a tab bar in view controller one. I am trying to detect if this tabaritem is touched inside view controller 2. What is the best method to perform such a task? I can post more specific code if you would like.
视图控制器 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
推荐答案
你应该使用 UITabBarControllerDelegate.请参阅:http://developer.apple.com/library/ios/#documentation/uikit/reference/UITabBarControllerDelegate_Protocol/Reference/Reference.html
You should use UITabBarControllerDelegate. See: http://developer.apple.com/library/ios/#documentation/uikit/reference/UITabBarControllerDelegate_Protocol/Reference/Reference.html
更具体地说,看看
tabBarController:didSelectViewController:
告诉委托人用户在标签栏中选择了一个项目."
"Tells the delegate that the user selected an item in the tab bar."
这篇关于我有一个标签栏,我试图检测它是否在视图控制器 2 中被触摸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!