popViewController 不会删除 UINavigationBar 项目

发布于 2024-10-20 17:03:19 字数 938 浏览 2 评论 0原文

我有一个奇怪的问题。我在这里和互联网上找到了一些提示,但没有解决我的问题。所以发生的事情是这样的:

我有一个包含 9 个项目的 TabBar 导航。它们都是 UINavigationItems。在某些情况下,我将其中一个视图控制器替换为另一个视图控制器。

为此,我使用 popViewController 和 pushViewController。这工作完美,但我有问题,UINavigationBar 与此不同步。这样的效果是我看到了正确的视图,但是当我单击“后退”按钮时,它会切换到一个空的导航栏项目,然后从那里我回到 rootViewController(例如“更多”)。

这是我的代码:


- (void)viewWillAppear:(BOOL)animated { 
  if ([[myAppDelegate bcUser] userLoggedIn]) {
    // user is logged in
    MyDataLoggedInViewController *loggedInViewController = [[[MyDataLoggedInViewController alloc] initWithNibName:@"MyDataLoggedInView" bundle:nil] autorelease];
    UINavigationController *navController = self.navigationController;
    [[self retain] autorelease];

    [navController popViewControllerAnimated:YES];
    [navController pushViewController:loggedInViewController animated:YES];
  } 
}

我希望有人可以提供帮助。我尝试了我发现的一切,但没有任何帮助。 :-/

谢谢并致以最美好的祝愿, 托马斯

I have a strange problem. I found some tipps here and in the internet but I nothing solved my problem. So here is what happens:

I have a TabBar Navigation with 9 items. All of them are UINavigationItems. On one of them I replace the default viewController with another one under certain conditions.

To do that, I use popViewController and pushViewController. This works perfectly but I have the problem, that the UINavigationBar is not in sync with that. That has the effect that I see the correct view but the when I click on the "back" button it shift's to an empty navbar item and from there I come back to the rootViewController ("more" for example).

Here is my code:


- (void)viewWillAppear:(BOOL)animated { 
  if ([[myAppDelegate bcUser] userLoggedIn]) {
    // user is logged in
    MyDataLoggedInViewController *loggedInViewController = [[[MyDataLoggedInViewController alloc] initWithNibName:@"MyDataLoggedInView" bundle:nil] autorelease];
    UINavigationController *navController = self.navigationController;
    [[self retain] autorelease];

    [navController popViewControllerAnimated:YES];
    [navController pushViewController:loggedInViewController animated:YES];
  } 
}

I hope someone can help. I tried everything I found and nothing helped. :-/

Thanks and best wishes,
Thomas

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

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

发布评论

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

评论(1

眉目亦如画i 2024-10-27 17:03:19

尝试设置:

[navController popViewControllerAnimated:NO];
[navController pushViewController:loggedInViewController animated:NO];

因为您很可能正在等待动画完成。

Try setting:

[navController popViewControllerAnimated:NO];
[navController pushViewController:loggedInViewController animated:NO];

because you're most likely waiting for animations to complete.

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