【问题标题】:TableView within NavigationBar within TabBar Navigation?TabBar Navigation 中 NavigationBar 中的 TableView?
【发布时间】:2011-06-16 13:07:29
【问题描述】:

我正在构建一个具有多个级别的应用程序。

  • 第一级是屏幕底部的选项卡。 (主窗口)

  • 二级是 TableView(位置)中每个选项卡显示的内容

  • 第三级是第二级内容中所选项目的详细概述。 (位置详情)

第一和第二级工作正常。现在我想创建详细概述的内容。我创建了一个名为 LocationDetails.xib 的新 NIB。它只包含一些静态文本(插入的文本视图)。这样我就可以查看加载的窗口了。

在 Locations.m 文件中,我有以下功能:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

NSString * locationCity = [[locations objectAtIndex:indexPath.row] objectForKey:@"city"];

NSLog(@"Your choice is: %@", locationCity);

在这个函数中,我想转到另一个视图(LocationDetails)。最好的方法是什么。如果我没有给你足够的信息,请告诉我!我可以提供您需要的所有信息!

希望尽快收到您的来信!

致以诚挚的问候,

杜威

【问题讨论】:

    标签: iphone cocoa-touch tableview tabbar


    【解决方案1】:

    我会使用导航控制器。

    在您的主 xib 文件中,您最终会得到如下内容:

    UITabBarViewController // Main Window
      tab 1:
        UINavigationController
          UITableView // (Locations)
    
      tab 2:
        UINavigationController
          UITableView // (Locations)
    

    然后,在您的LocatonDetails 上滑动的代码很简单:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        LocationDetailsViewController = [[LocationDetailsViewController alloc] initWithNibName:@"LocationDetails" bundle:nil];
        controller setLocation:[locations objectAtIndex:indexPath.row]];
        [[self navigationController] pushViewController:controller animated:YES];
        [controller release];
    }
    

    【讨论】:

    • 嗨,院长,感谢您的快速回复。这是否意味着我的基本窗口(MainWindow)是一个 TabBar 窗口,我的第二个窗口是一个 NavigationBased 窗口,在导航窗口的视图中带有一个 TableView?
    • 等等 - 你应该在 iPhone 应用程序中只拥有一个 UIWindow。我认为本教程应该解释我的意思:b00gizm.posterous.com/…
    • 嗨,院长!再次感谢!我将遵循本教程!我会回来回复这个帖子的,好吗?谢谢你的回复!!!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-07-14
    • 1970-01-01
    • 2013-10-22
    • 2014-05-18
    • 2017-09-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多