我使用自定义的 UINavigationController
作为 rootViewController。 UINavigationController 的
第一个viewController 是一个UITabBarController
。每个 UITabBarController
都是一个自定义的 UINavigationConller
。当显示 tabBarController
时,我隐藏了 rootViewController 的
navigationBar
。
Init the
UITabbarController
+(RDVTabBarController *)tabBarControllertWithIndexNSUInteger)index
{
UIViewController *goodsHomeController = [[ESGoodsHomeViewController alloc] initWithNibName:nil bundle:nil];
UINavigationController *goodsHomeNavi = [[ESNavigationController alloc]
initWithRootViewController:goodsHomeController];
........
ESTabBarController *tabBarController = [[ESTabBarController alloc] init]; //对status bar 能定制
[tabBarController setViewControllers[goodsHomeNavi,categoryNavi,shoppingCarNavi,userCenterNavi]];
return tabBarController;
}
Set it to a
navigationController
self.tabController = [UIHelper tabBarControllertWithIndex:0];
self.tableController.delegate = self;
UINavigationController *tabBarNavigation = [UIHelper navigationControllerViewController:self.tableController];
tabBarNavigation.navigationBarHidden = TRUE;
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
self.window.rootViewController = tabBarNavigation;
In the baseViewController ,I customise the back item in the navigationBar
- (void)setCustomNavigationBackButton
{
UIImage *backBtn = [UIImage imageNamed"bar_back"];
UIImage *backDownBtn = [UIImage imageNamed"bar_back_down"];
backBtn = [backBtn imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
backDownBtn = [backDownBtn imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
self.navigationItem.backBarButtonItem.title=@"";
self.navigationController.navigationBar.backIndicatorImage = backBtn;
self.navigationController.navigationBar.backIndicatorTransitionMaskImage = backBtn;
}
In some cases, I change the
viewControllers
of anavigationController
when I push aviewController
after the push animation is finished. I use a navigationController+block
- (void)popToViewControllerUIViewController *)viewController animatedBOOL)animated onCompletionvoid(^)(void))completion
{
[CATransaction begin];
[CATransaction setCompletionBlock:completion];
[self popToViewController:viewController animated:animated];
[CATransaction commit];
}
完成后执行 block
[UIHelper viewController:self pushViewControllerrderDetail completion:^{
NSMutableArray *afterController = [NSMutableArray array]; //将本页面删除
NSArray *viewController = self.navigationController.viewControllers;
[viewController enumerateObjectsUsingBlock:^(UIViewController *obj, NSUInteger idx, BOOL *stop) {
if (![obj isKindOfClass:[ESPurchaseViewController class]]) {
[afterController addObjectbj];
}
}];
self.navigationController.viewControllers = afterController;
}];
在某些推送中,当我从 UITabBarController
推送到 secondViewController
时,我隐藏 navigationBar
并显示根 navigationBar
.
+(void)tabControllerUIViewController *)tabController pushSubControllerUIViewController *)subViewController
{
[tabController.rdv_tabBarController.navigationController pushViewController:subViewController animated:YES];
tabController.rdv_tabBarController.navigationController.navigationBarHidden = FALSE;
}
找不到导航弹不出来的原因。这并不总是发生。
关于 UINavigationContller
,UITabBarController
,UIViewController
的 iOS 基础知识有什么错误需要我知道吗?
谢谢!
如果我认为您的需要是 First MainNavigationViewController 然后是 tabbar Controller ,并且每个标签栏的 View Controller 也有自己的导航 Controller ,那么它会正常工作..
listViewController = [[CBListViewController alloc] initWithStyle:UITableViewStylePlain];
bookmarkController = [[CBBookmarksViewController alloc] initWithStyle:UITableViewStylePlain];
settingsController = [[CBActivityViewController alloc] init ];
searchController = [[CBSearchViewController alloc] initWithNibName"CBSearchViewController" bundle:nil];
nearbyController = [[CBViewOnMapViewController alloc] init ];
UINavigationController *bNavigationController = [[UINavigationController alloc] initWithRootViewController:bookmarkController];
self.navigationControllerForBookmark = bNavigationController;
UITabBarItem *tab2=[[UITabBarItem alloc]init];
tab2.image = [[UIImage imageNamed"bookmark.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
tab2.selectedImage = [[UIImage imageNamed"bookmark_active.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
tab2.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0);
navigationControllerForBookmark.tabBarItem = tab2;
UINavigationController *cNavigationController = [[UINavigationController alloc] initWithRootViewController:settingsController];
self.navigationControllerForSettings = cNavigationController;
UITabBarItem *tab3=[[UITabBarItem alloc]init];
tab3.image = [[UIImage imageNamed"activites.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
tab3.selectedImage = [[UIImage imageNamed"activites_active.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
tab3.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0);
navigationControllerForSettings.tabBarItem = tab3;
UINavigationController *dNavigationController = [[UINavigationController alloc] initWithRootViewController:searchController];
self.navigationControllerForSearch = dNavigationController;
UITabBarItem *tab4=[[UITabBarItem alloc]init];
tab4.image = [[UIImage imageNamed"Search.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
tab4.selectedImage = [[UIImage imageNamed"Search_active.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
self.navigationController.tabBarItem = tab4;
tab4.imageInsets=UIEdgeInsetsMake(5, 0, -5, 0);
navigationControllerForSearch.tabBarItem=tab4;
UINavigationController *eNavigationController = [[UINavigationController alloc] initWithRootViewController:nearbyController];
self.navigationControllerForNearby = eNavigationController;
UITabBarItem *tab5=[[UITabBarItem alloc]init];
tab5.image = [[UIImage imageNamed:@"nearby.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
tab5.selectedImage = [[UIImage imageNamed:@"nearby_active.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
self.navigationController.tabBarItem = tab5;
tab5.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0);
navigationControllerForNearby.tabBarItem = tab5;
[navigationControllerForNearby.navigationBar setBackgroundImage:[UIImage imageNamed:@"headerBar"] forBarMetrics:UIBarMetricsDefault];
UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:listViewController];
self.navigationController = aNavigationController;
UITabBarItem *tab1=[[UITabBarItem alloc]init];
tab1.image = [[UIImage imageNamed:@"review.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
tab1.selectedImage = [[UIImage imageNamed:@"review_active.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
tab1.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0);
navigationController.tabBarItem = tab1;
[[UITabBar appearance] setBarTintColor:GRAY_COLOR];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:navigationController, navigationControllerForNearby, navigationControllerForSearch, navigationControllerForBookmark, navigationControllerForSettings, nil];
self.window.rootViewController = self.tabBarController;
请检查这是否解决了您的问题,先生。
关于ios - UINavigationView 不能弹出,只有导航弹出动画,UIViewController 没变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32430751/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |