iphone开发如何隐藏各种bar

转载至:http://blog.csdn.net/riveram/article/details/7291142

状态条StatusBar

[cpp] view plaincopyprint?
  1. [UIApplication sharedApplication].statusBarHidden = YES;  
[UIApplication sharedApplication].statusBarHidden = YES;

 导航条NavigationBar

[cpp] view plaincopyprint?
  1. [self.navigationController setNavigationBarHidden:YES];  
[self.navigationController setNavigationBarHidden:YES];


TabBar

方法1

[cpp] view plaincopyprint?
  1. [self.tabBarController.tabBar setHidden:YES];  
[self.tabBarController.tabBar setHidden:YES];


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

方法2

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

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

[cpp] view plaincopyprint?
  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.  }  
// The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization.
self.hidesBottomBarWhenPushed = YES;
}
return self;
}

方法3

[cpp] view plaincopyprint?
  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.  }  
- (void)makeTabBarHidden:(BOOL)hide
{
if ( [self.tabBarController.view.subviews count] < 2 )
{
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];
}
//    [UIView beginAnimations:@"TabbarHide" context:nil];
if ( hide )
{
contentView.frame = self.tabBarController.view.bounds;        
}
else
{
contentView.frame = CGRectMake(self.tabBarController.view.bounds.origin.x,
self.tabBarController.view.bounds.origin.y,
self.tabBarController.view.bounds.size.width,
self.tabBarController.view.bounds.size.height - self.tabBarController.tabBar.frame.size.height);
}
self.tabBarController.tabBar.hidden = hide;
//    [UIView commitAnimations];   
}



时机

[cpp] view plaincopyprint?
  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.  }  
- (void)viewWillAppear:(BOOL)animated {
[self setFullScreen:YES];
}
- (void)viewWillDisappear:(BOOL)animated {
[self setFullScreen:NO];
}
- (void)setFullScreen:(BOOL)fullScreen {
// 状态条
[UIApplication sharedApplication].statusBarHidden = fullScreen;
// 导航条
[self.navigationController setNavigationBarHidden:fullScreen];
// tabBar的隐藏通过在初始化方法中设置hidesBottomBarWhenPushed属性来实现。
}


本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/388358.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Swift5.1 语言指南(九) 闭包

★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号&#xff1a;山青咏芝&#xff08;shanqingyongzhi&#xff09;➤博客园地址&#xff1a;山青咏芝&#xff08;https://www.cnblogs.com/strengthen/&#xff09;➤GitHub地址&a…

服务器被攻击怎么修改,服务器一直被攻击怎么办?

原标题&#xff1a;服务器一直被攻击怎么办&#xff1f;有很多人问说&#xff0c;网站一直被攻击&#xff0c;什么被挂马&#xff0c;什么被黑&#xff0c;每天一早打开网站&#xff0c;总是会出现各种各样的问题&#xff0c;这着实让站长们揪心。从修改服务器管理账号开始&…

脚本 api_从脚本到预测API

脚本 apiThis is the continuation of my previous article:这是我上一篇文章的延续&#xff1a; From Jupyter Notebook To Scripts从Jupyter Notebook到脚本 Last time we discussed how to convert Jupyter Notebook to scripts, together with all sorts of basic engine…

Iphone代码创建视图

要想以编程的方式创建视图&#xff0c;需要使用视图控制器中定义的viewDidLoad方法&#xff0c;只有在运行期间生成UI时才需要实现该方法。 在此只贴出viewDidLoad方法的代码&#xff0c;因为只需要在这个方法里面编写代码&#xff1a; [cpp] view plaincopyprint?- (void)vi…

聊聊flink Table的OrderBy及Limit

序 本文主要研究一下flink Table的OrderBy及Limit 实例 Table in tableEnv.fromDataSet(ds, "a, b, c"); Table result in.orderBy("a.asc");Table in tableEnv.fromDataSet(ds, "a, b, c");// returns the first 5 records from the sorted …

binary masks_Python中的Masks概念

binary masksAll men are sculptors, constantly chipping away the unwanted parts of their lives, trying to create their idea of a masterpiece … Eddie Murphy所有的人都是雕塑家&#xff0c;不断地消除生活中不必要的部分&#xff0c;试图建立自己的杰作理念……埃迪墨…

css+沿正方形旋转,CSS3+SVG+JS 正方形沿着正方本中轴移动翻转的动画

CSS语言&#xff1a;CSSSCSS确定* {margin: 0;padding: 0;fill: currentColor;vector-effect: non-scaling-stroke;}html {overflow: hidden;}body {display: flex;flex-direction: column;margin: 0;min-width: 10em;height: 100vh;}body > svg,body > input,body > …

Iphone在ScrollView下点击TextField使文本筐不被键盘遮住

1.拖一个Scroll View视图填充View窗口&#xff0c;将Scroll View视图拖大一些&#xff0c;使其超出屏幕。 2.向Scroll View拖&#xff08;添加&#xff09;多个Label视图和Text View视图。 3.在.h头文件中添加如下代码&#xff1a; [cpp] view plaincopyprint?#import <U…

两高发布司法解释 依法严惩涉地下钱庄犯罪

新华社北京1月31日电&#xff08;记者丁小溪&#xff09;最高人民法院、最高人民检察院31日联合发布关于办理非法从事资金支付结算业务、非法买卖外汇刑事案件适用法律若干问题的解释&#xff0c;旨在依法惩治非法从事资金支付结算业务、非法买卖外汇犯罪活动&#xff0c;维护金…

python 仪表盘_如何使用Python刮除仪表板

python 仪表盘Dashboard scraping is a useful skill to have when the only way to interact with the data you need is through a dashboard. We’re going to learn how to scrape data from a dashboard using the Selenium and Beautiful Soup packages in Python. The S…

VS2015 定时服务及控制端

一. 服务端 如下图—新建项目—经典桌面—Windows服务—起名svrr2. 打到server1 改名为svrExecSqlInsert 右击对应的设计界面&#xff0c;添加安装服务目录结构如图 3. svrExecSqlInsert里有打到OnStart()方法开始写代码如下 /// <summary>/// 服务开启操作/// </su…

css文件如何设置scss,Webpack - 如何将scss编译成单独的css文件?

2 个答案:答案 0 :(得分&#xff1a;3)这是我在尝试将css编译成单独文件时使用的webpack.config.js文件|-- App|-- dist|-- src|-- css|-- header.css|-- sass|-- img|-- partials|-- _variables.scss|-- main.scss|--ts|-- tsconfig.json|-- user.ts|-- main.js|-- app.js|-- …

Iphone表视图的简单操作

1.创建一个Navigation—based—Application项目&#xff0c;这样Interface Builder中会自动生成一个Table View&#xff0c;然后将Search Bar拖放到表示图上&#xff0c;以我们要给表示图添加搜索功能&#xff0c;不要忘记将Search Bar的delegate连接到File‘s Owner项&#xf…

PhantomJS的使用

PhantomJS安装下载地址 配置环境变量 成功&#xff01; 转载于:https://www.cnblogs.com/hankleo/p/9736323.html

aws emr 大数据分析_DataOps —使用AWS Lambda和Amazon EMR的全自动,低成本数据管道

aws emr 大数据分析Progression is continuous. Taking a flashback journey through my 25 years career in information technology, I have experienced several phases of progression and adaptation.进步是连续的。 在我25年的信息技术职业生涯中经历了一次闪回之旅&…

21eval 函数

eval() 函数十分强大 ---- 将字符串 当成 有效的表达式 来求职 并 返回计算结果 1 # 基本的数学计算2 print(eval("1 1")) # 23 4 # 字符串重复5 print(eval("* * 5")) # *****6 7 # 将字符串转换成列表8 print(eval("[1, 2, 3, 4]")) # [1,…

联想r630服务器开启虚拟化,整合虚拟化 联想万全R630服务器上市

虚拟化技术的突飞猛进&#xff0c;对运行虚拟化应用的服务器平台的运算性能提出了更高的要求。近日&#xff0c;联想万全R630G7正式对外发布。这款计算性能强劲&#xff0c;IO吞吐能力强大的四路四核服务器&#xff0c;主要面向高端企业级应用而开发。不仅能够完美承载大规模数…

Iphone屏幕旋转

该示例是想在手机屏幕方向发生改变时重新定位视图&#xff08;这里是一个button&#xff09; 1.创建一个View—based Application项目,并在View窗口中添加一个Round Rect Button视图&#xff0c;通过尺寸检查器设置其位置&#xff0c;然后单击View窗口右上角的箭头图标来旋转窗…

先进的NumPy数据科学

We will be covering some of the advanced concepts of NumPy specifically functions and methods required to work on a realtime dataset. Concepts covered here are more than enough to start your journey with data.我们将介绍NumPy的一些高级概念&#xff0c;特别是…

lsof命令详解

基础命令学习目录首页 原文链接&#xff1a;https://www.cnblogs.com/ggjucheng/archive/2012/01/08/2316599.html 简介 lsof(list open files)是一个列出当前系统打开文件的工具。在linux环境下&#xff0c;任何事物都以文件的形式存在&#xff0c;通过文件不仅仅可以访问常规…