iPhone:选择选项卡栏中的表格单元格时更改视图

发布于 2024-12-29 19:12:20 字数 959 浏览 2 评论 0原文

我有一个有 2 个视图的 UITabBar。 一个视图包含一个 UITable。当我选择一个单元格时,我想导航到另一个视图。

我总是用这段代码来做到这一点:

 if(self.damageController == nil)
    {

        DamageControllerOverview *viewTwo = [[DamageControllerOverview alloc] initWithNibName:@"DamageControllerOverview" bundle:[NSBundle mainBundle]];


        self.damageController = viewTwo;
        self.damageController.damageAccount = damageAccount;
        self.damageController.ma = ma;

        [self.navigationController setNavigationBarHidden:NO animated:NO];

        temporaryBarButtonItem = [[UIBarButtonItem alloc] init];
        temporaryBarButtonItem.title = @"Back";

        self.navigationItem.backBarButtonItem = temporaryBarButtonItem;

        [viewTwo release];
    }

    [self.navigationController pushViewController:self.damageController animated:YES]; 

但是由于我在选项卡栏中有表格,所以它不再工作了。 有人知道为什么吗?

此致 梅兰妮

*编辑: 这不是我的根视图控制器。 我已经有一个导航控制器,并且不想在选项卡栏中创建新的导航控制器

I have a UITabBar with 2 views.
One view contains a UITable. When I am selecting a cell I want to navigate to another view.

I always did it with this code:

 if(self.damageController == nil)
    {

        DamageControllerOverview *viewTwo = [[DamageControllerOverview alloc] initWithNibName:@"DamageControllerOverview" bundle:[NSBundle mainBundle]];


        self.damageController = viewTwo;
        self.damageController.damageAccount = damageAccount;
        self.damageController.ma = ma;

        [self.navigationController setNavigationBarHidden:NO animated:NO];

        temporaryBarButtonItem = [[UIBarButtonItem alloc] init];
        temporaryBarButtonItem.title = @"Back";

        self.navigationItem.backBarButtonItem = temporaryBarButtonItem;

        [viewTwo release];
    }

    [self.navigationController pushViewController:self.damageController animated:YES]; 

But since I have the table in the Tabbar it is not working anymore.
Does anybody know why?

Best regards
Melanie

*Edit:
this is not my rootviewcontroller.
I already have a navigationcontroller and don't want to create a new one in the tabbar

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

等风来 2025-01-05 19:12:20

我从你的问题中了解到的是

1-你在主窗口中有一个 tabbar
2-然后标签栏中就有一个 navigationController

所以你需要通过这种方式将控制器推送到navigationController。

[self.tabBarController.navigationController pushViewController:self.damageController animated:YES];

而不是
[self.navigationController PushViewController:self.damageControlleranimated:YES];

我希望它有帮助

What i understand from your question is that

1- you have a tabbar in the main window
2-then you have a navigationController in the tabbar.

so you need to push your controller to the navigationController this way.

[self.tabBarController.navigationController pushViewController:self.damageController animated:YES];

instead of
[self.navigationController pushViewController:self.damageController animated:YES];

I hope it helps

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