• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - UINavigationView 不能弹出,只有导航弹出动画,UIViewController 没变

[复制链接]
菜鸟教程小白 发表于 2022-12-13 10:23:54 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我使用自定义的 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 a navigationController when I push a viewController 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 基础知识有什么错误需要我知道吗? 谢谢!



Best Answer-推荐答案


如果我认为您的需要是 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/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap