Reputation:
I have a view and the user is in this view, and there is no way to go away. There is an ad, and than after a period of time the "go" button appears, or better, it goes to next view automatically! I'm using a storyboard.
Upvotes: 5
Views: 3840
Reputation: 356
Swift 4
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(2)) {
self.performSegue(withIdentifier: "segueName", sender: self)
}
Upvotes: 0
Reputation: 2800
You'll have to do it in code. It's as simple as:
- (void)goToNextView {
[self performSegueWithIdentifier:@"segueToNextView" sender:self];
}
- (void)viewDidLoad {
[self performSelector:@selector(goToNextView) withObject:nil afterDelay:5];
}
Now segueToNextView
will happen 5 seconds after the view controller loads.
Upvotes: 7
Reputation: 7563
certainly, add the timer, and then in the timer handler, call performSegueWithIdentifier:sender:
. you'll have to do this in code; you'll get the name of the segue as you set it in the storyboard, and then use that as the identifier argument to the call.
Upvotes: 1