ios automatically segue from one screen to another

旧时模样 提交于 2020-01-16 01:15:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!