选项卡/导航混合,如 iPod/音乐
我正在开发一个应用程序,我希望使用与 iPod/音乐应用程序用来导航播放列表相同的导航和选项卡栏混合体。
基本上:
- 导航用于深入研究特定的列表树。
- 底部的选项卡栏可在列表之间切换,该选项卡出现在大多数/所有子屏幕上。
- 标签栏的内容在所有屏幕之间都是不变的。
- 标签栏对被点击的反应在所有屏幕上都是相同的:它将用户一直弹出到根目录并将其放入该列表中。
导航嵌入选项卡,选项卡嵌入导航?似乎两者都不会达到我想要的效果。另一方面,如果我坚持使用基本的导航应用程序并仅添加选项卡,我是否会需要很多额外的代码?
对此最好的基本方法是什么?
I'm working on an application that I'd like to use the same hybrid of navigation and tab bars that the iPod/Music application uses to navigate playlists.
Basically:
- Navigation to deal with delving deeper into a particular list tree.
- A tab bar along the bottom to switch between lists, which appears on most/all subscreens.
- The tab bar's contents are constant between all screens.
- The tab bar's reaction to being tapped is the same on all screens: it pops the user all the way back to the root and puts them on that list.
Navigation embedded in tabs, tabs embedded in navigation? Neither seems like it will do quite what I want. On the other hand, if I stick with a basic navigation app and just add the tabs, aren't I going to have a lot of extra code?
What's the best basic approach for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我已经构建了专门执行此操作的应用程序。考虑它的最好方法是从最狭窄的部分开始,即各个视图控制器。在 iPod 示例中,这将包括艺术家、专辑、播放列表、歌曲等的控制器。请注意,如果您点击播放列表,它会将您带到歌曲列表。这是两个独立的视图控制器。
您在 iPod 应用程序上看到的每个选项卡中都有一个导航控制器。导航控制器包装应用程序选项卡的根视图控制器。然后将每个导航控制器设置为选项卡控制器的 ViewController。代码看起来像这样
如果您想处理从播放列表 -> 所选播放列表中的歌曲列表的转换,您可以在播放列表视图控制器中执行此操作(
[self.navigationController PushViewController:theListOfSongsViewController动画:当然为什么不]
)。I've built apps which do just this. The best way to think about it is to start at the most narrow part, the individual view controllers. In the iPod example, this would include controllers for Artists, Albums, Playlists, Songs, etc. Note if you tap on a playlist, it takes you to a list of songs. These are two separate view controllers.
Each of tabs you see on the iPod app have a Navigation controller in them. The nav controller wraps the root view controllers of the tabs of the app. And then each of the nav controllers are set as the ViewControllers of the tab controller. The code would look something like this
If you wanted to handle the transition from say, Playlists->List of songs in a selected playlist, you would do this in the Playlist viewcontroller (
[self.navigationController pushViewController:theListOfSongsViewController animated:SUREWHYNOT]
).到目前为止,我正在查看每个窗格中带有 UINavigationControllers 的 UITabBarController,其中包含一些自定义代码,用于将目标选项卡上的导航控制器弹出到选项卡开关上的根目录。
So far, I'm looking at a UITabBarController with UINavigationControllers in each pane with a little custom code to pop the navigation controller on the target tab back to the root on a tab switch.
Apple 有一些关于组合视图控制器(选项卡控制器内的导航控制器)的精彩文档
http://developer.apple.com/iphone/library/featuredarticles/ViewControllerPGforiPhoneOS/CombiningViewControllers/CombiningViewControllers.html
Apple has some great documentation on combining view controllers (navigation controllers inside tab controllers)
http://developer.apple.com/iphone/library/featuredarticles/ViewControllerPGforiPhoneOS/CombiningViewControllers/CombiningViewControllers.html