Question

I am wondering if there is a way to automatically go to another ViewController after an certain number of seconds... I am trying to create a splash screen, but I don't want to use a launch image. Does anyone have any experience with this? Thanks!

Was it helpful?

Solution

In your storyboard, create a segue from the splash screen view controller to the home page view controller (your splash screen's destination). Rename the segue identifier to "HomePageSegue".

In SplashScreenViewController.m

- (void)viewWillAppear:(BOOL)animated {
    [self performSegueWithIdentifier: @"HomePageSegue" sender:self];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"HomePageSegue"]) {

        // Get destination view
        UIViewController *homeVC = [segue destinationViewController];

        // Pass the information to your destination view
        [self presentViewController:homeVC animated:YES completion:nil];
    }
}

This will present the home page as soon as soon as the splash screen loaded. Feel free to create a timer before [self performSegueWithIdentifier:sender:] is called.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top