从UITabBarController子视图推送时,为什么self.navigationController为NULL [英] Why is self.navigationController NULL when pushed from UITabBarController subviews

查看:68
本文介绍了从UITabBarController子视图推送时,为什么self.navigationController为NULL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这就是我在做什么.我有一个带有5个标签的 tabBarControllerOne .单击其中一个选项卡后,我呈现了一个模态视图控制器,该控制器具有一个NavigationBar和一个 TabBarControllerTwo (带有3个选项卡).这三个选项卡是这里值得关注的问题.

This is what I am doing. I have a tabBarControllerOne with 5 tabs. On clicking one of the tabs, I present a modal view controller, which has a navigationBar and a TabBarControllerTwo (with 3 tabs). These three tabs are the matter for concern here.

tabBarController 的第五个标签中,我将modalViewController显示为

In the 5th Tab of tabBarController I show modalViewController as

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:self.nextTabView];
  //  navController.navigationBarHidden = YES;


navController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

NSLog(@"Displauing the navcontroller before pushing %@", navController);

[self presentModalViewController:navController animated:NO];

在这里, nextTabView 是一个带有3个标签的tabBarController.视图起作用.在视图中,如果我尝试类似的方法.

Here, nextTabView is a tabBarController with 3 tabs. The views work. In the views, if I try something like.

self.navigationController.navigationBarHidden = YES;
[self.navigationController pushViewController: someController animated:YES];


// nothing works.

如果我是NSLog,它将 self.navigationController 显示为(null)

If I NSLog, it displays self.navigationController as (null)

有人可以告诉我为什么这不起作用吗?

Can someone tell me why this is not working ?

推荐答案

不支持在 UINavigationController 内嵌入 UITabBarController .Apple具有仔细的容器视图控制器层次结构,并且 UITabBarController 必须是其视图控制器层次结构的根.

Embedding a UITabBarController inside a UINavigationController is not supported. Apple has a careful hierarchy of container view controllers, and a UITabBarController must be the root of its view controller hierarchy.

此外,正如乔指出的那样,您的视图不属于导航控制器;它们属于标签栏控制器,因此未设置其 navigationController 属性.

Additionally, as Joe points out, your views don't belong to the navigation controller; they belong to the tab bar controller, so their navigationController property is not set.

这篇关于从UITabBarController子视图推送时,为什么self.navigationController为NULL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆