选项卡/导航混合,如 iPod/音乐

发布于 2024-08-12 10:46:43 字数 342 浏览 6 评论 0原文

我正在开发一个应用程序,我希望使用与 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

黑凤梨 2024-08-19 10:46:43

我已经构建了专门执行此操作的应用程序。考虑它的最好方法是从最狭窄的部分开始,即各个视图控制器。在 iPod 示例中,这将包括艺术家、专辑、播放列表、歌曲等的控制器。请注意,如果您点击播放列表,它会将您带到歌曲列表。这是两个独立的视图控制器。

您在 iPod 应用程序上看到的每个选项卡中都有一个导航控制器。导航控制器包装应用程序选项卡的根视图控制器。然后将每个导航控制器设置为选项卡控制器的 ViewController。代码看起来像这样

FirstTabViewController *first = [[FirstTabViewController alloc] init...];
SecondTabViewController *second = ...;

UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:first];
UINavigationController *nav2 = [[UINavigationController alloc] initWithRootViewController:second];

myTabBarController.viewControllers = [NSArray arrayWithObjects:nav1, nav2, nil];
// Then make sure to release things to avoid leaks

如果您想处理从播放列表 -> 所选播放列表中的歌曲列表的转换,您可以在播放列表视图控制器中执行此操作([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

FirstTabViewController *first = [[FirstTabViewController alloc] init...];
SecondTabViewController *second = ...;

UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:first];
UINavigationController *nav2 = [[UINavigationController alloc] initWithRootViewController:second];

myTabBarController.viewControllers = [NSArray arrayWithObjects:nav1, nav2, nil];
// Then make sure to release things to avoid leaks

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]).

寄居人 2024-08-19 10:46:43

到目前为止,我正在查看每个窗格中带有 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.

陈独秀 2024-08-19 10:46:43

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文