這個(gè)重要是接上一篇文章:
我的問(wèn)題如下:
簡(jiǎn)單說(shuō)就是,首頁(yè)導(dǎo)航欄隱藏,進(jìn)入到下一個(gè)界面,顯示導(dǎo)航欄,同時(shí)要把底部的tabbar隱藏,好簡(jiǎn)單的需求.
我的做法如下(部分代碼):
#import "ViewController.h"
#import "NextVC.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:NO];
}
- (void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:NO animated:NO];
}
- (void)viewDidLoad {
[super viewDidLoad];
UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(100, 300, 100, 30)];
btn.backgroundColor = [UIColor orangeColor];
[btn addTarget:self action:@selector(goNextVC) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
UIImageView *headbackImgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 375, 150)];
headbackImgView.clipsToBounds = YES;
headbackImgView.image = [UIImage imageNamed:@"infoBackground"];
headbackImgView.contentMode = UIViewContentModeScaleAspectFill;
[self.view addSubview:headbackImgView];
}
-(void)goNextVC{
NextVC *nextVC = [[NextVC alloc] init];
/*
坑點(diǎn): hidesBottomBarWhenPushed 會(huì)導(dǎo)致導(dǎo)航欄閃一下;
*/
nextVC.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:nextVC animated:YES];
}
看到這個(gè)代碼,感覺(jué)好像沒(méi)啥問(wèn)題啊;然而,hidesBottomBarWhenPushed有坑,會(huì)導(dǎo)致下一級(jí)界面的導(dǎo)航欄閃一下.
之前沒(méi)發(fā)現(xiàn)是這個(gè)hidesBottomBarWhenPushed屬性設(shè)置導(dǎo)致的,所以解決辦法也不相同;
解決辦法
我唯一驗(yàn)證通過(guò)的辦法是,通過(guò)XIB去設(shè)置,如下:
把這個(gè)勾上,就不需要代碼設(shè)置了,bug也完美解決;
遺留問(wèn)題:
如果沒(méi)有用xib的咋辦? 好吧,我也不知道,沒(méi)找到對(duì)應(yīng)的解決辦法;??????