xcode 结合标签栏、导航和表格视图控制器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26061725/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 05:42:25  来源:igfitidea点击:

Combining Tab Bar, Navigation and Table View Controllers

iosobjective-cxcodeuinavigationcontrolleruitabbarcontroller

提问by Leandro

So i would like to combine a Tab bar, Navigation and Table View controller. I have had difficulties finding an example that does this because i only found for tutorials for old versions of xcode such as 3 and 4.

所以我想结合一个标签栏、导航和表格视图控制器。我很难找到执行此操作的示例,因为我只找到了适用于旧版本 xcode(例如 3 和 4)的教程。

How can i combine them all together? If you could provide me with example code, links ,videos anything is helpful thank you! I have also read that i need to have the table view as the root view if thats correct?

我怎样才能把它们组合在一起?如果您能向我提供示例代码、链接、视频,任何事情都会有帮助,谢谢!我还读到我需要将表视图作为根视图,如果那是正确的?

Any code that i would have to implement in the .h or .m file would be appreciated since i am a beginner in xcode!

我必须在 .h 或 .m 文件中实现的任何代码都将不胜感激,因为我是 xcode 的初学者!

Note i am using storyboards!!

请注意,我正在使用故事板!!

Here is an example of what i want to achieve you can fast forward it to 00:53 https://www.youtube.com/watch?v=LBnPfAtswgw

这是我想要实现的示例,您可以将其快进到 00:53 https://www.youtube.com/watch?v=LBnPfAtswgw

i am using: Xcode Version 6.0.1 (6A317)

我正在使用:Xcode 版本 6.0.1 (6A317)

回答by Leandro

If you drag and drop a tabBarController in your storyboard, it will be attached to two viewControllers. Let's say you want the first viewController to be a navigationController: select it, press Editor > Embed In > Navigation Controller. Now, you'll see your viewController attached to a navigationController attached to your tabBarController. You can put a tableView inside it, if you want. Then you need to assign each viewController to your custom classes.

如果您在故事板中拖放一个 tabBarController,它将附加到两个视图控制器。假设您希望第一个 viewController 是一个 navigationController:选择它,按 Editor > Embed In > Navigation Controller。现在,您将看到您的 viewController 附加到一个导航控制器附加到您的 tabBarController。如果需要,您可以在其中放置一个 tableView。然后您需要将每个 viewController 分配给您的自定义类。

I think this tutorial will help you a lot: http://www.raywenderlich.com/50308/storyboards-tutorial-in-ios-7-part-1. In fact, it uses tabBar, navigation and tableView.

我认为本教程会对您有很大帮助:http: //www.raywenderlich.com/50308/storyboards-tutorial-in-ios-7-part-1。事实上,它使用了tabBar、导航和tableView。

回答by BoBo

There is a great tutorial series about iOS programming in AppCoda. Tutorial #11 is detail instruction for embedding navigation controller in tab bar controller to build complete app. I think that tutorials in AppCoda will be helpful to you.

AppCoda 中有一个关于 iOS 编程的很棒的教程系列。教程 #11 是在标签栏控制器中嵌入导航控制器以构建完整应用程序的详细说明。我认为 AppCoda 中的教程会对您有所帮助。