问题
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
回答1:
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
}
}
回答2:
You can call performSegueWithIdentifier
[self performSegueWithIdentifier:@"mySegueIdentifier" sender:self];
来源:https://stackoverflow.com/questions/19857726/ios-automatically-segue-from-one-screen-to-another