首页 > 移动平台 > 详细

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

时间:2014-11-06 14:52:55      阅读:455      评论:0      收藏:0      [点我收藏+]
以下两种情况是我在开发过程中遇到的,一种是代码使用pushViewController,另一种是storyboard直接使用push。之前也查阅了很多关于隐藏底部tabbar的资料,但是要么使用起来麻烦,要么就是藕合度高代码不规范(这里有点代码洁癖,当前类相关的事务应该写在本类中)。
1、使用pushViewController
如A->B;A是列表页,带有tabbar;B是内容页,不需要tabbar;

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

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

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.hidesBottomBarWhenPushed=YES;
}
return self;
}

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

bubuko.com,布布扣

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

bubuko.com,布布扣


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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!