Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
977 views
in Technique[技术] by (71.8m points)

swift - what would be a proper storyboard example of combining nav bars and tab bars in one app?

Hi I'm new to ios app dev. I've only done tutorials so far that have covered apps with either nav bars or tab bars. Now I want to make an app combining both.

So, say I have an app with a tab bar at the bottom with two tabs: friends and enemies. In each tab i plan to have a running list of who my friends and enemies are, so it will need an addPerson button on the nav bar of each tab.

given that scenario, what would be the proper way to organize my controllers and views and stuff? would both my tab controller and my nav controller be pointing to the same view controller?

i'm having trouble conceptualizing how my nav controller(2 nav controllers now?) would work in a more complex app.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here is how to set it up in your Storyboard. The TabBarController is the main controller. Each item of the TabBarController has its own NavigationController:

enter image description here

You probably want to use a TableViewController for your lists. Here I have shown the TableViewController as the rootViewController of the NavigationController.

A quick way to construct this is to delete everything in the Storyboard and then drag out two TableViewControllers placing one directly above the other. Select both by dragging an outline around them both, and then select Editor->Embed In->Tab Bar Controller from the menu. Then select each TableViewController in turn and select Editor->Embed In->Navigation Controller.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...