I have a scenario like this: I have a MovieViewController
it serves as my intro for my app(It is the Initial View Controller in my storyboard). Its goes to another view controller named MenuViewController
either by:
So the sequence now is this: MovieViewController
-----> MenuViewController
---> (Then three buttons corresponding to different Views)
According to my older question here: Warning about window hierarchy
I correspond to the answer and edit my code, but still the error occurs in my debugger.
Warning: Attempt to present on whose view is not in the window hierarchy!
It still occurs several times, Is there a way to make the MenuViewController
the main view after MovieViewController
is shown? or dismiss/ remove it after the movie ends/shown.
Thanks for your guide.
To attempt to answer this question I am going to make the assumption that when you say
main view
You mean root view.
A simple solution is that when you start your app a navigation controller is created which manages the stack of the view controllers. This navigation controller has a root controller which you should set as your MenuViewController
(This should be the first view controller loaded) as this is the controller you will want to return to. You can present your MovieViewController
as a view on top of your MenuViewController
that way when the MovieViewController
is dismissed you will be presented with the MenuViewController
.
On a side note, it is generally not good practice in iOS programming to present a splash screen, where a splash screen is a screen with no functional value other than to delay the presentation of the master view while loading and present information regarding the app.
You can make your MenuViewController
initial view controller, and immediately after it is loaded call:
[self presentModalViewController:MovieViewController animated:NO];
Then when you want to remove MovieViewController
from the screen just call:
[self dismissModalViewControllerAnimated:YES];
in MovieViewController
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.