无法呈现和关闭模态视图控制器

发布于 2024-11-03 04:21:27 字数 701 浏览 5 评论 0原文

我有一个带有工具栏的 OpenGL-ES 应用程序。当我触摸工具栏上的配置图标时,我的应用程序使用以下代码显示一个带有一堆配置选项的视图:

optionsControllerOutlet.modalPresentationStyle = UIModalPresentationFullScreen;
optionsControllerOutlet.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self.glView.superview addSubview:optionsControllerOutlet.view];
[self presentModalViewController:optionsControllerOutlet animated:YES];

当我尝试关闭该视图时,将执行以下代码:

[self dismissModalViewControllerAnimated:YES];

除了动画之外,视图显示正常过渡中缺失。当我试图消除这种观点时,什么也没有发生。知道为什么没有动画并且它没有消失吗?我刚刚开始了解视图控制器以及如何使用它们。我可以通过使用以下行来关闭视图来使其工作,但我想让它正常工作:

[optionsControllerOutlet.view removeFromSuperview];

I have an OpenGL-ES app with a toolbar. When I touch the configure icon on my toolbar, my app displays a view with a bunch of configuration options using the following code:

optionsControllerOutlet.modalPresentationStyle = UIModalPresentationFullScreen;
optionsControllerOutlet.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self.glView.superview addSubview:optionsControllerOutlet.view];
[self presentModalViewController:optionsControllerOutlet animated:YES];

and when I try to dismiss the view, the following code gets executed:

[self dismissModalViewControllerAnimated:YES];

The view comes up fine except the animation is missing from the transition. When I try to dismiss the view, nothing happens. Any idea why there is no animation and it's not dismissing? I'm just starting to wrap my head around view controllers and how to work with them. I can get it to work by using the following line to dismiss the view, but I'd like to get this working properly:

[optionsControllerOutlet.view removeFromSuperview];

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

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

发布评论

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

评论(2

開玄 2024-11-10 04:21:27

您不应该需要

[self.glView.superview addSubview:optionsControllerOutlet.view]

也不应该需要removeSubview 方法。模态视图应该负责它的呈现。所以你的错误可能在其他地方。

关于解雇,你在哪里调用:

[self dismissModalViewControllerAnimated:YES];

这意味着被发送到呈现模式视图控制器的视图控制器,即父视图控制器。通常,您将父级设置为委托,然后调用从父级中消除当前模式视图的方法。

或者,如果您想从模态视图本身调用它,可以运行:

[self.presentingViewController DismissModalViewControllerAnimated:YES];

You shouldn't need

[self.glView.superview addSubview:optionsControllerOutlet.view]

Nor should you need the removeSubview method. The modal view is supposed to take care of its presentation. So your error might be somewhere else.

Regarding dismissal, where are you calling:

[self dismissModalViewControllerAnimated:YES];

This is meant to be sent to the view controller that presesnts the modal view controller, i.e. the parent view controller. Typically, you set the parent as the delegate and then call a method that dismisses the current modal view from within the parent.

Or, if you want to call it from the modal view itself, it is possible to run:

[self.presentingViewController dismissModalViewControllerAnimated:YES];

荒芜了季节 2024-11-10 04:21:27

摆脱 [self.glView.superview addSubview:optionsControllerOutlet.view]; ?

Get rid of [self.glView.superview addSubview:optionsControllerOutlet.view]; ?

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