关于UITabBarController的UITabBar隐藏问题
2016-03-11 16:40
411 查看
最开始的时候我用的
- (void)hideTabBar {
if (self.tabBarController.tabBar.hidden
== YES) {
return;
}
UIView *contentView;
if ( [[self.tabBarController.view.subviews
objectAtIndex:0]
isKindOfClass:[UITabBar
class]] )
contentView = [self.tabBarController.view.subviews
objectAtIndex:1];
else
contentView = [self.tabBarController.view.subviews
objectAtIndex:0];
contentView.frame =
CGRectMake(contentView.bounds.origin.x, contentView.bounds.origin.y,
contentView.bounds.size.width, contentView.bounds.size.height
+ self.tabBarController.tabBar.frame.size.height);
self.tabBarController.tabBar.hidden =
YES;
}
- (void)showTabBar
{
if (self.tabBarController.tabBar.hidden ==
NO)
{
return;
}
UIView *contentView;
if ([[self.tabBarController.view.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]]){
contentView = [self.tabBarController.view.subviews objectAtIndex:1];
}else{
contentView = [self.tabBarController.view.subviews objectAtIndex:0];
}
contentView.frame = CGRectMake(contentView.bounds.origin.x, contentView.bounds.origin.y, contentView.bounds.size.width, contentView.bounds.size.height -
self.tabBarController.tabBar.frame.size.height);
self.tabBarController.tabBar.hidden =
NO;
}
但是发现控制器里面有多层的话就隐藏就会失效,而且这个方法一般用在iOS7之前的系统,iOS7之后出现了
hidesBottomBarWhenPushed
这个属性,确实是非常的神奇,一句话就可以隐藏UITabBar。
根据我的项目中的经验,要么项目中全用hidesBottomBarWhenPushed 要么全用iOS7之前的方法。
项目中两者混用确实把我给坑了一把(比如融云的SDK不知道用的什么方法,而你的项目却用的iOS7之前的方法),建议以后全用hidesBottomBarWhenPushed避免不必要的问题发生,
- (void)hideTabBar {
if (self.tabBarController.tabBar.hidden
== YES) {
return;
}
UIView *contentView;
if ( [[self.tabBarController.view.subviews
objectAtIndex:0]
isKindOfClass:[UITabBar
class]] )
contentView = [self.tabBarController.view.subviews
objectAtIndex:1];
else
contentView = [self.tabBarController.view.subviews
objectAtIndex:0];
contentView.frame =
CGRectMake(contentView.bounds.origin.x, contentView.bounds.origin.y,
contentView.bounds.size.width, contentView.bounds.size.height
+ self.tabBarController.tabBar.frame.size.height);
self.tabBarController.tabBar.hidden =
YES;
}
- (void)showTabBar
{
if (self.tabBarController.tabBar.hidden ==
NO)
{
return;
}
UIView *contentView;
if ([[self.tabBarController.view.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]]){
contentView = [self.tabBarController.view.subviews objectAtIndex:1];
}else{
contentView = [self.tabBarController.view.subviews objectAtIndex:0];
}
contentView.frame = CGRectMake(contentView.bounds.origin.x, contentView.bounds.origin.y, contentView.bounds.size.width, contentView.bounds.size.height -
self.tabBarController.tabBar.frame.size.height);
self.tabBarController.tabBar.hidden =
NO;
}
但是发现控制器里面有多层的话就隐藏就会失效,而且这个方法一般用在iOS7之前的系统,iOS7之后出现了
hidesBottomBarWhenPushed
这个属性,确实是非常的神奇,一句话就可以隐藏UITabBar。
根据我的项目中的经验,要么项目中全用hidesBottomBarWhenPushed 要么全用iOS7之前的方法。
项目中两者混用确实把我给坑了一把(比如融云的SDK不知道用的什么方法,而你的项目却用的iOS7之前的方法),建议以后全用hidesBottomBarWhenPushed避免不必要的问题发生,
相关文章推荐
- Android requires compiler compliance level 5.0 or 6.0. Found '1.8' instead. 解决办法
- iOS - UIViewAnimation
- android 如何在广播里面更新 UI
- UVA 540 - Team Queue
- iOS开发UI篇—懒加载
- 使用fruitstrap实现命令行把最新IPA包更新到iPhone设备上
- iOS -UIImage
- uva 540 Team Queue
- iOS巅峰之将UIView转换成UIImage
- HTML滚动文字代码 marquee标签
- UITextView & UITextField 实现中英文混合输入的限制
- IOS_画图 图片等比压缩 IOS_UIImage
- Request failed: unacceptable content-type: text/html
- PAT (Advanced Level) Practise 1041 Be Unique (20)
- 解决[INSTALL_FAILED_UID_CHANGED]无法安装包问题
- Request failed: internal server error (500)
- An SDK corresponding to WDK version '8.1' was not found. Please install the SDK before building.
- 51. N-Queens 52. N-Queens II *HARD*
- UGUI中点击鼠标绘制图片
- leetcode 62. Unique Paths-唯一路径|动态规划