正在挑选哪个选项卡控制器?(Which tab controller is the one being picked?)
我有一个带五个按钮的标签栏控制器。 该控制器有一个选项卡视图控制器。
标签视图控制器应该根据被按下的标签而有所不同。
例如,如果选项卡是“位置”,则应根据位置对显示的数据进行排序。 如果标签是“字母表”,那么视图应该根据字母排序。
我在视图控制器中有这个代码
-(void)viewWillAppear:(BOOL)animated { [super viewDidLoad]; [BUtilitiesQuick parseXMLFileAtURL:@"http:///BusinessSerialized.xml"]; [BUtilitiesQuick UtilitiesQuick].BizsToDisplay = [BUtilitiesQuick searchObjectsInContext:@"Business" :nil :@"Title" :YES]; SLog(@"%@",[self tabBarController]); if ([[self tabBarController]selectedIndex]==0) { } SLog(@"%d",[[self tabBarController] selectedIndex]); // Do any additional setup after loading the view from its nib. }该[[self tabBarController] selectedIndex]工程,除了一个问题。 而不是给出当前选定的索引,它是以前的索引。
说我现在选择标签0,然后点击标签4; SLog()将显示0。
我该如何解决这个问题? 我想知道被按下的标签。
I have a tab bar controller with five butt. That controller has a tab view controller.
The tab view controller should behave differently depending on the tab being pressed.
For example, if the tab is "location", then the displayed data should be sorted based on location. If the tab is "alphabet", then the view should be sorted based on the alphabet.
I have this code in the view controller
-(void)viewWillAppear:(BOOL)animated { [super viewDidLoad]; [BUtilitiesQuick parseXMLFileAtURL:@"http:///BusinessSerialized.xml"]; [BUtilitiesQuick UtilitiesQuick].BizsToDisplay = [BUtilitiesQuick searchObjectsInContext:@"Business" :nil :@"Title" :YES]; SLog(@"%@",[self tabBarController]); if ([[self tabBarController]selectedIndex]==0) { } SLog(@"%d",[[self tabBarController] selectedIndex]); // Do any additional setup after loading the view from its nib. }That [[self tabBarController] selectedIndex] works, except for one problem. Rather than giving the current selected index, it's the previous index.
Say I am now selecting tab 0, and I click tab 4; that SLog() will display 0.
How can I solve this? I want to know the tab being pressed.
最满意答案
通过使用这种委托方法,您将获得您选择的索引:
# enter code here - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { SLog(@"sff %d",tabBarController.selectedIndex); }By using this delegate method you will be getting your selected index:
# enter code here - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { SLog(@"sff %d",tabBarController.selectedIndex); }#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格
推荐阅读
留言与评论(共有 19 条评论) |
本站网友 唐英杰 | 27分钟前 发表 |
如果选项卡是“位置” | |
本站网友 zappos | 3分钟前 发表 |
@"http | |
本站网友 k589 | 30分钟前 发表 |
例如 | |
本站网友 槐花怎么吃 | 11分钟前 发表 |
(UITabBarController *)tabBarController didSelectViewController | |
本站网友 东四十条 | 24分钟前 发表 |
@"http | |
本站网友 日批是什么意思 | 30分钟前 发表 |
then the view should be sorted based on the alphabet. I have this code in the view controller -(void)viewWillAppear | |
本站网友 汉京山 | 22分钟前 发表 |
(UIViewController *)viewController { SLog(@"sff %d" | |
本站网友 合兴 | 12分钟前 发表 |
该控制器有一个选项卡视图控制器 | |
本站网友 焦作阳光男科医院 | 15分钟前 发表 |
如果选项卡是“位置” | |
本站网友 水电三局贴吧 | 14分钟前 发表 |
如果选项卡是“位置” | |
本站网友 潍坊房产网 | 24分钟前 发表 |
[[self tabBarController] selectedIndex]); // Do any additional setup after loading the view from its nib. } 该[[self tabBarController] selectedIndex]工程 | |
本站网友 凯润金城 | 26分钟前 发表 |
///BusinessSerialized.xml"]; [BUtilitiesQuick UtilitiesQuick].BizsToDisplay = [BUtilitiesQuick searchObjectsInContext | |
本站网友 合肥万达影城 | 17分钟前 发表 |
nil | |
本站网友 无锡九龙仓玺园 | 23分钟前 发表 |
# enter code here - (void)tabBarController | |
本站网友 房产代理 | 21分钟前 发表 |
[self tabBarController]); if ([[self tabBarController]selectedIndex]==0) { } SLog(@"%d" | |
本站网友 胜泰华府 | 5分钟前 发表 |
(BOOL)animated { [super viewDidLoad]; [BUtilitiesQuick parseXMLFileAtURL | |
本站网友 百度分享工具 | 23分钟前 发表 |
@"http | |
本站网友 轻松理财普卡 | 20分钟前 发表 |
正在挑选哪个选项卡控制器?(Which tab controller is the one being picked?) 我有一个带五个按钮的标签栏控制器 |