Can I add a timer to my view to go to the next view?

I have a view, and a user in that view, and there is no way to leave. An ad appears, and after a while the "go" button appears, or, better, it automatically goes on to the next view! I use a storyboard.

+5
source share
3 answers

You will need to do this in code. It is as simple as:

- (void)goToNextView {
    [self performSegueWithIdentifier:@"segueToNextView" sender:self];
}

- (void)viewDidLoad {
    [self performSelector:@selector(goToNextView) withObject:nil afterDelay:5];
}

Now it segueToNextViewwill happen 5 seconds after the controller boots up.

+8
source

, , performSegueWithIdentifier:sender:. ; segue, , .

+2

Swift 4

DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(2)) {
  self.performSegue(withIdentifier: "segueName", sender: self)
}
0
source

All Articles