drlobo
drlobo

Reputation: 2159

ios automatically segue from one screen to another

So I have learnt how to segue from one screen to another when user presses a button. This is all handled in StoryBoard by literally pointing the button to the next screen.

However I would like to have a page that will automatically segue to another page after some data has been downloaded (so no user interaction).

What method call do I need to call from my ViewController class so that it calls the segue to be performed ?

Thanks

Upvotes: 1

Views: 2916

Answers (2)

Suhit Patil
Suhit Patil

Reputation: 12023

create a segue from firstviewcontroller(data download view controller) to another viewcontroller. give segue the identifier e.g. nextView

now in the method where data gets downloaded, after the download you can call

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

and in prepareForSegue: method

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"nextView"]) 
    {
        NextViewController *nextVC = [segue destinationViewController];
        //pass any data to next view here

    }
}

Upvotes: 2

user1567896
user1567896

Reputation: 2398

You can call performSegueWithIdentifier

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

Upvotes: 1

Related Questions