简体   繁体   English

导航 controller 不显示 iphone

[英]navigation controller doesn't show up iphone

I have an application with a tab bar as the root controller.我有一个带有标签栏的应用程序作为根 controller。 I have four items in the tabbar.我在标签栏中有四个项目。 The second item is a table view and this should have a navigation controller of course, the thing is that i don't even get the navigation bar to show up and i have no idea how to do it.第二个项目是一个表格视图,它应该有一个导航 controller 当然,问题是我什至没有显示导航栏,我不知道该怎么做。 So i tried to guess after a long time in google without success.所以我在谷歌中尝试了很长时间但没有成功。 This is what i did in the viewDidLoad method:这就是我在 viewDidLoad 方法中所做的:

SearchNavController *navController = [[SearchNavController alloc]init];

    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:navController];

    [searchNavController release];

With that i got an IlegalArgumentException.有了这个,我得到了一个 IlegalArgumentException。 How can i get the navigation bar to show up?如何让导航栏显示?

Thanks in advance guys提前谢谢各位

Have a nice day!祝你今天过得愉快!

Your navController should probably an ordinary UIViewController with the view you want to display.你的navController应该是一个普通的 UIViewController 和你想要显示的视图。 Also you need the following to actually display the navigationController:您还需要以下内容才能实际显示导航控制器:

[self presentModalViewController:navigationController animated:YES];

The navigation controller should now show up with your view as it's content.导航 controller 现在应该与您的视图一起显示为它的内容。

Since you used interface builder to setup your tabbarcontroller.由于您使用界面构建器来设置标签栏控制器。 follow the following steps to get navigation bar and navigation controller in your tabbarcontroller:按照以下步骤在 tabbarcontroller 中获取导航栏和导航 controller:

Open Mainwindow.xib and select tababarcontroller.打开 Mainwindow.xib 和 select tababarcontroller。 In the attribute inspector, select the item1 in viewcontroller and from the arrows to the right change it to navigation controller.在属性检查器中,select 视图控制器中的 item1 并从右侧的箭头将其更改为导航 controller。

Try this link:试试这个链接:
link 1 链接 1

IF you are using interface builder.如果您使用的是界面生成器。 Then Add UINavigation controller in each tab bar then add your view controller in uinavigation conrtroller.然后在每个标签栏中添加 UINavigation controller 然后在 uinavigation 控制器中添加您的视图 controller。 If you have 4 tabs then you have to put 4 navigation controller.如果你有 4 个标签,那么你必须放置 4 个导航 controller。

UITabbarcontroller ->>Tab Bar >> UINavigationController >> set its class to your viewcontroller UITabbarcontroller ->>Tab Bar >> UINavigationController >> 将其 class 设置为您的视图控制器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM