双击UITabBarControllers选项卡转到导航控制器的根目录 [英] Double Clicking on UITabBarControllers Tab goes to root of Navigation controller

查看:241
本文介绍了双击UITabBarControllers选项卡转到导航控制器的根目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有2个UINavigationControllers的UITabBarController设置。

I have a UITabBarController setup with 2 UINavigationControllers.

一个UINavigationController有一个UIViewController,另一个UINavigationController有两个UIViewControllers。然后,如果您导航到第二个UIViewController并单击已选中的选项卡,则会将您带到UINavigationController的根目录(这将是第一个UIViewController)。

One UINavigationController has One UIViewController, the other UINavigationController has Two UIViewControllers. If you then navigate to the second UIViewController and click the Tab that is already selected it bring you to the root of the UINavigationController (This would be the first UIViewController).

有没有办法阻止这种情况发生?我不希望用户能够单击已选择的选项卡以转到导航控制器的根目录。

Is there a way to stop this from happening? I do not want the user to be able to click an already selected Tab to go to the root of the Navigation Controller.

推荐答案

要做到这一点,你需要在app委托中实现一个函数来获取tabbar委托调用。

To do this you need to implement a function in your app delegate to pick up the tabbar delegate calls.

在你的app delegate.m文件中,在didfinishlaunching方法中,添加这一行

In your app delegate.m file, in the didfinishlaunching method, add this line

[tabBarController setDelegate:self];

然后实现此方法(也在你的app委托中):

then implement this method (also in your app delegate):

- (BOOL)tabBarController:(UITabBarController *)theTabBarController shouldSelectViewController:(UIViewController *)viewController
{
  return (theTabBarController.selectedViewController != viewController);
}

这将作为选项卡委托协议的一部分进行调用,并将停止选择一个标签,如果它已经是选定的标签。

This gets called as part of the tab delegate protocol and will stop the selection of a tab if its already the selected one.

希望有帮助。

这篇关于双击UITabBarControllers选项卡转到导航控制器的根目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆