无法呈现和关闭模态视图控制器
我有一个带有工具栏的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不应该需要
也不应该需要removeSubview 方法。模态视图应该负责它的呈现。所以你的错误可能在其他地方。
关于解雇,你在哪里调用:
这意味着被发送到呈现模式视图控制器的视图控制器,即父视图控制器。通常,您将父级设置为委托,然后调用从父级中消除当前模式视图的方法。
或者,如果您想从模态视图本身调用它,可以运行:
[self.presentingViewController DismissModalViewControllerAnimated:YES];
You shouldn't need
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:
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];
摆脱 [self.glView.superview addSubview:optionsControllerOutlet.view]; ?
Get rid of [self.glView.superview addSubview:optionsControllerOutlet.view]; ?