单击UITabBarController时的自定义操作 [英] Custom action when clicking on UITabBarController

查看:161
本文介绍了单击UITabBarController时的自定义操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个标签栏控制器,其中添加了四个导航控制器。导航控制器在选项卡栏控制器中显示为选项卡栏项目。现在我想在标签栏中添加第五个按钮,它不会打开另一个视图,但会触发一些自定义代码。我想在点击该标签栏项目时显示一个重叠的共享菜单,无论用户在哪四个页面中。我该怎么做?

I have a Tab Bar Controller with four navigation controllers added to it. The navigation controllers appear as Tab Bar Items in the Tab Bar Controller. Now I want to add a fifth button to the tab bar, that does not open another view, but triggers some custom code. I want to display an overlaying "share menu" when clicking that Tab Bar Item regardless on which of the four pages the user is. How can I do that?

推荐答案

我可以建议将虚拟UIViewController添加到最后一个索引并处理UITabBarControllerDelegate

I can suggest to add dummy UIViewController to the last index and handle UITabBarControllerDelegate

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {

    if ([viewController == ...your dummy view controller...]) {

        //Your custom action

        return NO;
    }

    return YES;
}

这篇关于单击UITabBarController时的自定义操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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