I am a new iOS developer and I am currently building a game for the iPhone, and I am writing it in Objective-C.
This question will probably be very easy to answer but I couldn't find it anywhere else. I am using storyboards in this app and I was using them fine when a user pressed a button to go to the next storyboard, however for this when the segue needs to occur automatically I am completely stumped as to how to achieve this.
I want to have a logo appear for about five seconds when the app is launched, then the main menu should appear. I am trying to use performSegueWithIdentifier:sender: to achieve this, however I have browsed apple's documentation and it doesn't really answer my question on how this method is used.
I know what this method is used for, just not what code I need to type to correctly use it.
Also if I am using the completely wrong method, or there's a much easier way to achieve what I am trying to do, that would be much appreciated. Any help is useful. Thanks in advance
To make a kind of 'splash screen' for your app, just create the view for it in your Storyboard and set it as the entry point (or root of a Navigation Controller etc). Create a segue like you have previously, except drag a segue from the 'Splash' view controller, to the 'Main Menu' controller. With the segue selected, set its Identifier in the Attributes inspector to ShowMainMenu
.
Create a method in the 'Splash' view controller that performs the segue:
- (void)showMainMenu {
[self performSegueWithIdentifier:@"ShowMainMenu" sender:self];
}
In the 'Splash' view controller's viewDiDLoad
method, add:
[self performSelector:@selector(showMainMenu) withObject:nil afterDelay:5.0];
There you have it!