获取触摸的 tabBar 索引
当我触摸选项卡时,如何获取 tabBar 的索引?
我已将课程延长至< UITabBarController > >并添加了方法
- (void)tabBarController:(UITabBarController *)tabBarController
didSelectViewController:(UIViewController *)viewController
{
if (viewController == tabBarController.moreNavigationController)
{
tabBarController.moreNavigationController.delegate = self;
}
}
,但当我触摸选项卡项目时,该方法不会被触发。 我应该怎么办?
How can i get the index of the tabBar when i touch a tab?
I´ve extended my class to < UITabBarController > and added the method
- (void)tabBarController:(UITabBarController *)tabBarController
didSelectViewController:(UIViewController *)viewController
{
if (viewController == tabBarController.moreNavigationController)
{
tabBarController.moreNavigationController.delegate = self;
}
}
But that method isn´t triggered when i touch a tab item.
What should i do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
UITabBarController 有一个属性
selectedIndex
,您可以使用它来查找选定的选项卡。有关 UITabBarController 的更多信息可以在此处< /a>
另外请务必设置 UITabBarController 的
delegate
属性,否则委托消息(例如didSelectViewController:
)将不会被 已收到。UITabBarController has a property
selectedIndex
that you can use to find the selected tab.More information about the UITabBarController can be found here
Also be sure to set the
delegate
property of your UITabBarController, otherwise the delegate messages (such asdidSelectViewController:
) will not be received.您在创建 UITabBarController 时是否将其委托设置为委托类?
Did you set the delegate of the
UITabBarController
to your delegate class when you create it?