popViewController 不工作
我遇到了 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我遇到了类似的问题,我通过使用
希望有所帮助来修复它。
I had a similar problem I fixed it by using
Hope that helps.
不确定你想要完成什么;但尝试将其添加到 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 initialpushViewController
call.您应该等到用户消除警报。这减少了用户的困惑。
您回复我的评论说它有效,出于某种我不明白的神奇原因。
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.
您应该在 -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.
如果您从主从模板创建项目,请删除拆分视图控制器。
If you created your project from master-detail template, remove the split view controller.