popViewController 不会删除 UINavigationBar 项目
我有一个奇怪的问题。我在这里和互联网上找到了一些提示,但没有解决我的问题。所以发生的事情是这样的:
我有一个包含 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试设置:
因为您很可能正在等待动画完成。
Try setting:
because you're most likely waiting for animations to complete.