iOS使用push隐藏子页面底部bottom TabBar

原文地址:http://blog.csdn.net/wuwo333/article/details/40860047

以下两种情况是我在开发过程中遇到的,一种是代码使用pushViewController,另一种是storyboard直接使用push。之前也查阅了很多关于隐藏底部tabbar的资料,但是要么使用起来麻烦,要么就是藕合度高代码不规范(这里有点代码洁癖,当前类相关的事务应该写在本类中)。

1、使用pushViewController
如A->B;A是列表页,带有tabbar;B是内容页,不需要tabbar;

在A的事件中打开B,如下代码

[objc]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. -(void)showVideo:(EJAlbumModel *)model bySId:(NSString *)sid{  
  2. NSLog(@"%@",@"执行委托");  
  3. EJClassVideoViewController *videoController=[[EJClassVideoViewController alloc] init];  
  4. videoController.model=model;  
  5. videoController.semesterClassId=sid;  
  6. self.navigationItem.backBarButtonItem=[[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStyleBordered target:nil action:nil];// 修改下级页面的返回按钮,此处我是很想写到videoController中,但是backBarButtonItem的机制决定必须写在A中;  
  7. [self.navigationController pushViewController:videoController animated:YES];  
  8. }  
在B的加载View视图事件initWithNibName中,加入 self.hidesBottomBarWhenPushed=YES;即可实现打开B隐藏tabbar,返回A重新现实tabbar;很简单吧

[objc]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil  
  2. {  
  3. self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];  
  4. if (self) {  
  5. self.hidesBottomBarWhenPushed=YES;  
  6. }  
  7. return self;  
  8. }  

2、使用storyboard
在storyboard中建立A和B,并使用ctrl+链接至B,即segue的打开方式;如下图所示:



此处只需要在可视化视图中修改B的一个属性即可(可惜很多技术文章都没提到这点,是因为我没有找到吗),如下图,选中B视图,并勾选Hide Bottom Bar on Push;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值