popViewController 不工作

发布于 2024-10-27 04:47:56 字数 1073 浏览 1 评论 0原文

我遇到了 popViewController 的问题。

我使用 pushViewController 转到 OrdersFormViewController

OrdersFormViewController *ordersFormViewController = [[OrdersFormViewController alloc] initWithNibName:@"OrdersFormViewController" bundle:nil];

[self.navigationController pushViewController:ordersFormViewController animated:YES];
[ordersFormViewController release];

OrdersFormViewController 我在 viewDidLoad 中显示 UIAlertView 并调用 popViewController< /code> 但这不起作用。

UIAlertView* alertView = [[UIAlertView alloc]
                         initWithTitle:@"Error"
                         message:@"Error"
                         delegate:self
                         cancelButtonTitle:@"OK"
                         otherButtonTitles:nil];
[alertView show];
[alertView release];

[self.navigationController popViewControllerAnimated:YES];

该视图不是从navigationController“弹出”的,但是当按下导航栏中的标准后退按钮时,只有导航栏发生变化,而不是实际视图。

有谁知道为什么会发生这种情况?

I am having an issue with popViewController.

I use pushViewController to go to OrdersFormViewController

OrdersFormViewController *ordersFormViewController = [[OrdersFormViewController alloc] initWithNibName:@"OrdersFormViewController" bundle:nil];

[self.navigationController pushViewController:ordersFormViewController animated:YES];
[ordersFormViewController release];

From OrdersFormViewController I display a UIAlertView in viewDidLoad and call popViewController but this is not working.

UIAlertView* alertView = [[UIAlertView alloc]
                         initWithTitle:@"Error"
                         message:@"Error"
                         delegate:self
                         cancelButtonTitle:@"OK"
                         otherButtonTitles:nil];
[alertView show];
[alertView release];

[self.navigationController popViewControllerAnimated:YES];

The view is not "popped" from the navigationController but when pushing the standard back button in the navigation bar, only the navigation bar changes and not the actual view.

Does anyone have an idea why this is happening?

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

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

发布评论

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

评论(5

多情癖 2024-11-03 04:47:56

我遇到了类似的问题,我通过使用

[self.parentViewController.navigationController popViewControllerAnimated:YES];

希望有所帮助来修复它。

I had a similar problem I fixed it by using

[self.parentViewController.navigationController popViewControllerAnimated:YES];

Hope that helps.

梦年海沫深 2024-11-03 04:47:56

不确定你想要完成什么;但尝试将其添加到 viewDidAppear 中。

在执行初始 pushViewController 调用之前,可能会调用 viewDidLoad

Not sure what you're trying to acomplish; but try adding it to viewDidAppear instead.

viewDidLoad may be getting called before you do the initial pushViewController call.

无远思近则忧 2024-11-03 04:47:56

您应该等到用户消除警报。这减少了用户的困惑。

您回复我的评论说它有效,出于某种我不明白的神奇原因。

You should wait till the user dismisses the alert. This makes less confusion to the user.

You replied to my comment that it worked, for some magical reason I don't understand.

り繁华旳梦境 2024-11-03 04:47:56

您应该在 -viewDidAppear: 方法中完成所有这些操作。当在此处调用时,动画序列当前正在进行中,并且您的控制器实际上尚未在屏幕上进行动画处理。等到屏幕上出现动画,然后就消失。

You should do all this in the -viewDidAppear: method. When called here, the animation sequence is currently in progress, and you controller will not have actually been animated onscreen yet. Wait until you've animated on screen, then dismiss yourself.

℉絮湮 2024-11-03 04:47:56

如果您从主从模板创建项目,请删除拆分视图控制器。

If you created your project from master-detail template, remove the split view controller.

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