iOS开发之隐藏tabbar解决隐藏后依然不能响应对应位置事件的问题

 
状态条StatusBar
1     [UIApplication sharedApplication].statusBarHidden = YES;
导航条NavigationBar
1     [self.navigationController setNavigationBarHidden:YES];
TabBar

方法1

1     [self.tabBarController.tabBar setHidden:YES];

这个方法有问题,虽然tabBar被隐藏了,但是那片区域变成了一片空白,无法被其他视图使用。

方法2

对于navigationController+tabBarController的结构,可以在push下一级的childController之前将childController的hidesBottomBarWhenPushed属性设为YES。

比如,可以在childController的初始化方法中做这件事,代码如下:

 
 1 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
 2 
 3 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
 4     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
 5     if (self) {
 6         // Custom initialization.
 7         self.hidesBottomBarWhenPushed = YES;
 8     }
 9     return self;
10 }
 

方法3

http://www.azumi.cc/thread-539502-1-1.html

 
 1 - (void)makeTabBarHidden:(BOOL)hide
 2 {
 3     if ( [self.tabBarController.view.subviews count] < 2 )
 4     {
 5         return;
 6     }
 7     UIView *contentView;
 8    
 9     if ( [[self.tabBarController.view.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]] )
10     {
11         contentView = [self.tabBarController.view.subviews objectAtIndex:1];
12     }
13     else
14     {
15         contentView = [self.tabBarController.view.subviews objectAtIndex:0];
16     }
17     //    [UIView beginAnimations:@"TabbarHide" context:nil];
18     if ( hide )
19     {
20         contentView.frame = self.tabBarController.view.bounds;        
21     }
22     else
23     {
24         contentView.frame = CGRectMake(self.tabBarController.view.bounds.origin.x,
25                                        self.tabBarController.view.bounds.origin.y,
26                                        self.tabBarController.view.bounds.size.width,
27                                        self.tabBarController.view.bounds.size.height - self.tabBarController.tabBar.frame.size.height);
28     }
29    
30     self.tabBarController.tabBar.hidden = hide;
31     //    [UIView commitAnimations];   
32 }
 
时机
 
 1 - (void)viewWillAppear:(BOOL)animated {
 2     [self setFullScreen:YES];
 3 }
 4 
 5 - (void)viewWillDisappear:(BOOL)animated {
 6     [self setFullScreen:NO];
 7 }
 8 
 9 - (void)setFullScreen:(BOOL)fullScreen {
10     // 状态条
11     [UIApplication sharedApplication].statusBarHidden = fullScreen;
12     // 导航条
13     [self.navigationController setNavigationBarHidden:fullScreen];
14     // tabBar的隐藏通过在初始化方法中设置hidesBottomBarWhenPushed属性来实现。
15 }
       相关文章: http://www.itnose.net/st/6251924.html
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值