开发者

trouble presenting and dismissing a modal view controller

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开发者_StackOverflow中文版.view removeFromSuperview];


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];


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜