Search code examples
iosobjective-cnstimersplash-screen

How to move from one view controller to another Automatically with some time?


I am new to this development and i was working with splash screen but I don't know how to move from one view controller to another with some certain time...

[self performSegueWithIdentifier:@"nameOfYourSegue" sender:self];

I don't know how to add time any help please.....


Solution

  • You can try

    // delay 1 second
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1.0 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
    
        [self performSegueWithIdentifier:@"segueID" sender:nil];
    });
    

    OR

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1.0 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
    
        UIViewController*vc = [self.storyboard instantiateViewControllerWithIdentifier:@"VCID"];
    
        [self presentViewController:vc animated:YES completion:nil];
    });