iOS开发-隐藏Tabbar的一些方法
2013-11-06 15:33
405 查看
由于手机界面比较小,有时候由于业务的需要,需要隐藏那个导航用的tabbar,方法有下面几个方法
方法一
YourAppDelegate *app = (YourAppDelegate *)[UIApplication sharedApplication].delegate;
NSArray *views = [app.tabBarController.view subviews];
for(id v in views){
if([v isKindOfClass:[UITabBar class]]){
[(UITabBar *)v setHidden:YES];
}
至于是隐藏还是显示根据自己的业务需求,在ViewController的不同的生命周期里执行,
推荐在下面2个方法里隐藏和显示
- (void)viewWillAppear: (BOOL)animated
- (void)viewWillDisappear: (BOOL)animated
方法二
[viewController setHidesBottomBarWhenPushed:YES];
这个方法在viewcontroller push navigation之前执行,也还比较方便
方法三
- (void) hideTabBar:(BOOL) hidden
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0];
for(UIView *view in self.tabBarController.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
if (hidden) {
[view setFrame:CGRectMake(view.frame.origin.x, 320, view.frame.size.width, view.frame.size.height)];
} else {
[view setFrame:CGRectMake(view.frame.origin.x, 320-49, view.frame.size.width, view.frame.size.height)];
}
}
else
{
if (hidden) {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 320)];
} else {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 320-49)];
}
}
}
[UIView commitAnimations];
}
这个方法,没有试过,如果把frame的位置调整好,应该是可以解决的但是在解决横屏和竖屏的时候,可能要花点功夫。
方法一
YourAppDelegate *app = (YourAppDelegate *)[UIApplication sharedApplication].delegate;
NSArray *views = [app.tabBarController.view subviews];
for(id v in views){
if([v isKindOfClass:[UITabBar class]]){
[(UITabBar *)v setHidden:YES];
}
至于是隐藏还是显示根据自己的业务需求,在ViewController的不同的生命周期里执行,
推荐在下面2个方法里隐藏和显示
- (void)viewWillAppear: (BOOL)animated
- (void)viewWillDisappear: (BOOL)animated
方法二
[viewController setHidesBottomBarWhenPushed:YES];
这个方法在viewcontroller push navigation之前执行,也还比较方便
方法三
- (void) hideTabBar:(BOOL) hidden
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0];
for(UIView *view in self.tabBarController.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
if (hidden) {
[view setFrame:CGRectMake(view.frame.origin.x, 320, view.frame.size.width, view.frame.size.height)];
} else {
[view setFrame:CGRectMake(view.frame.origin.x, 320-49, view.frame.size.width, view.frame.size.height)];
}
}
else
{
if (hidden) {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 320)];
} else {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 320-49)];
}
}
}
[UIView commitAnimations];
}
这个方法,没有试过,如果把frame的位置调整好,应该是可以解决的但是在解决横屏和竖屏的时候,可能要花点功夫。
相关文章推荐
- 隐藏TabBar的一些方法小结
- iOS开发中的一些常用方法
- 隐藏系统Tabbar的一些方法
- iOS开发textfield的一些方法汇总
- ios开发NSLocale的一些方法
- iOS开发隐藏键盘方法总结
- IOS开发点击空白处隐藏虚拟键盘的几种方法:
- 隐藏Tabbar的一些方法
- iOS开发textfield的一些方法汇总
- ios开发——点击空白处隐藏键盘的几种方法
- iOS开发 GCD一些常用的方法
- iOS开发之隐藏键盘的方法总结
- iOS 代码开发的小技巧(在别人博客的继承上添加一些方法)
- iOS开发隐藏键盘方法总结
- IOS开发——隐藏键盘的4种方法
- iOS开发隐藏键盘方法总结
- iOS开发隐藏键盘方法总结
- iOS跳转界面时隐藏tabBar的方法
- iOS开发中的一些常用方法
- 隐藏TabBar的一些方法小结