Skip to content

Instantly share code, notes, and snippets.

@wanggang316
Created June 14, 2014 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wanggang316/c5c4b66f527c42252afd to your computer and use it in GitHub Desktop.
Save wanggang316/c5c4b66f527c42252afd to your computer and use it in GitHub Desktop.
UINavigationController的几个问题
//1.UINaivgationController的bar有的需要隐藏,有的需要显示
//这时候可以重写UINavigationControllerDelegate的
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
if ( viewController == [MyViewController class]) {
[navigationController setNavigationBarHidden:YES animated:animated];
} else if ( [navigationController isNavigationBarHidden] ) {
[navigationController setNavigationBarHidden:NO animated:animated];
}
}
//但是这样push或者pop的时候navigation bar会有白边出现,也就是说bar隐藏或者显示的比较晚
//你可以这样做
//在你需要显示的bar的controller里
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:YES];
}
//隐藏则设置hidden位NO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment