IOS 点击tabbaritem跳转到一个新界面,且隐藏tabbar

先自定义一个UITabbarController,用于Storyboard中

再在MyTabbarController中实现protocol

@interface MyTabbarController : UITabBarController <UITabBarControllerDelegate>

@end

再实现代理里面的方法

@implementation MyTabbarController

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
    NSLog(@"shouldSelectViewController  %@", tabBarController.selectedViewController);
    if (viewController.tabBarItem.tag == 100) {
        DiaryViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:DIARY_VC_ID];
        [((UINavigationController *)tabBarController.selectedViewController) pushViewController:vc animated:YES];
        return NO;
    }
    return YES;
}

- (id)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if (self) {
        self.delegate = self;
    }
    return self;
}
@end

在要监听的tabbaritem跳转的viewcontroller中(比如点击一个item隐藏tabbar,而且有返回按钮)

则找到该tabbar,我的是父控件的tabbar,所以

- (void)viewWillAppear:(BOOL)animated {
    self.parentViewController.tabBarController.tabBar.hidden = YES;
}

点击返回按钮后回到开始所选中的tabbaritem

- (void)viewWillDisappear:(BOOL)animated {
    self.parentViewController.tabBarController.tabBar.hidden = NO;
}
时间: 2024-08-06 08:17:23

IOS 点击tabbaritem跳转到一个新界面,且隐藏tabbar的相关文章

JS解析Json 数据并跳转到一个新页面,取消A 标签跳转

JS解析Json 数据并跳转到一个新页面,代码如下 $.getJSON("http://api.cn.abb.com/common/api/staff/employee/" + obj.id, function (result) { window.open("https://abb-my.sharepoint.com/_layouts/15/me.aspx?p=" + result.Email, "_blank") }); 取消A 标签跳转 &l

关于登陆界面,页面没有刷新完毕,点击登陆跳转到一个接口的bug

现象 输入完密码点击登陆就跳转到了如下的页面 分析原因: 第一:查看html页面   页面中的html  登陆用的是form表单  表单中还写了属性  action   即允许跳到某一个接口,这里是没有必要的,  因为页面用的是js的跳转 第二:当页面因为某种原因,例如网速不好,没有加载完成的时候,这个时候用户直接点击按钮  button   因为有type=submit,加上有action的动作,所以页面跳转到了接口,后台因为session等的原因,提示了用户名密码错误 解决办法 首先去掉fo

iOS跳转界面时隐藏tabBar的方法

[1].[代码] [Objective-C]代码 1 2 3 4 5 6 7 8 9 10 11 12 13 //1.设置self.tabBarController.tabBar.hidden=YES;      self.tabBarController.tabBar.hidden=YES; //2.如果在push跳转时需要隐藏tabBar,设置self.hidesBottomBarWhenPushed=YES;     self.hidesBottomBarWhenPushed=YES;  

C#如何向word文档插入一个新段落及隐藏段落

向Word文档插入一个新段落的操作步骤 步骤1:新建一个文档并加载现有文档 Document document = new Document(); document.LoadFromFile(@"C:\Users\Administrator\Desktop\向日葵.docx", FileFormat.Docx); 步骤2:插入新段落并设置字体格式 Paragraph paraInserted = document.Sections[0].AddParagraph(); TextRang

iOS中点击按钮跳转到外部浏览器和内部打开

如图所示,需要实现点击一个按钮,跳转到指定网页: -(void)pushBtnCellClickDeleate{ NSLog(@"跳转"); //在APP内部打开指定网页 UIWebView *myWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)]; N

开发一个新的android界面、界面跳转 看图学Android---Android 开发实例教程三、四

Android实例图解教程目录 http://blog.csdn.net/wyx100/article/details/45061407 一.课程功能 本课程讲述建立一个新界面和界面切换(从界面一切换到界面二). 二.课程界面 界面一(启动界面) 界面二(主界面) 三.工作流程 完成页面切换需要2个过程: 1.建立一个工程,见第二节. http://blog.csdn.net/wyx100/article/details/45248209 可以在该项目基础继续开发. 2.建立开机界面 先引入资源

Fragment中启动一个新的Activity

最近遇到一个小问题,就是我在主界面中用的是Fragment,其中四个Fragment,然后打算在其中一个里边,写一个TextView(准确地说是Linearout)的单击事件,然后跳转到另外一个Activity,但是问题来了,不知道在哪个函数中去写. 平时我们的Activity都是重载onCreate()函数,但是在Fragment中重载的是onCreateView()函数,后来查了很多资料,大多都是两行代码或者几行代码,也弄不清具体怎么写,知道看到了一个博主的博客,Ta贴出来的整个代码(这里还

easyui 后台页面,在Tab中的链接点击后添加一个新TAB的解决方法

1.示例1 新增一个按钮 添加点击事件 onclick="self.parent.addTab('百度','http://www.baidu.com','icon-add')" 如: <a href="javascript:void(0)" title="google" onclick="self.parent.addTab('百度','http://www.baidu.com','icon-add')">打开新T

a标签跳转,打开一个新页面

a标签默认刷新本页面为最新页面 只需要给a标签加一个属性: target="_blank"      就可以在跳转的时候打开新的页面 < a href="index.html"  target="_blank" >跳转打开一个新的页面(不刷新本页)</a> 原文地址:https://www.cnblogs.com/PHP0222wangdong/p/11646113.html