我想为 mya 应用程序构建一个自定义标签栏,但有一个小问题:内置 tabBar 支持 hidesBottomBarWhenPushed
。有没有办法告诉我的应用程序我的 CustomTabBar
是底部栏? 这就是我想做的(相同的 UINavController):
+---------+ +---------+
|---------| |---------|
| | | |
| [btn] | ---> | 2nd |
| | | | view |
|---------| | | |
there's tabbar --> | 1 | 2 | | | | <- no tabbar
+---------+ | +---------+
|
pushViewController:animated:
我的 CustomTabBarController
的层次结构与原始 UITabBarController
的层次结构非常相似:
CustomTabBarController
|- UINavigationController (root: FirstViewController) <- there's a button
|- UINavigationController (root: SecondViewController)
有办法实现吗?提前致谢。
最佳答案
基于这个答案https://stackoverflow.com/a/4987542/263503 ,我在自定义选项卡栏 Controller 类中实现了以下内容:
CustomTabBarController.h
@interface CustomTabBarController : UITabBarController <UINavigationControllerDelegate>
CustomTabBarController.m
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController
animated:(BOOL)animated
{
if (viewController.hidesBottomBarWhenPushed) {
self.tabBarImage.hidden = YES;
} else if ([viewController isKindOfClass:[CustomViewController class]]) {
self.tabBarImage.hidden = NO;
}
}
此外,我需要知道何时再次显示选项卡栏的自定义图像。所以我检查添加到 tabBar.viewcontrollers 的 View Controller 的类
希望这有帮助。
关于iphone - hidesBottomBarWhenPushed 用于自定义 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10519927/