0

I have a project where a user fills in a web form, once the user hits submit it moves to a viewcontroller that shows a message "sent" or "error".

How can I make it automatically move to the main view controller without pressing a button, after a certain amount of seconds (so it displays the message "sent" for approx 2 - 3 seconds then moves to the main vc)

Any information would be highly appreciated, thankyou

Sean

2 Answers2

0

Have a look here: How do you trigger a block after a delay, like -performSelector:withObject:afterDelay:?

You can trigger some code inside a block to run after a specified delay. Inside that code you can include your code to navigate to the other view controller. The code for doing this depends on whether you are using storyboards or not. If you are using storyboards, you can use:

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

If you are not using storyboards, you can use the following to display the second view controller modally:

   [self presentModalViewController:myNewViewController animated:YES];
Community
  • 1
  • 1
Teevus
  • 1,104
  • 1
  • 10
  • 23
0

You should be able to show the view and, in the viewDidLoad method (or viewDidAppear), set a timer to call a method that dismisses the view controller. Use performSelector:withObject:afterDelay to perform the delay.

eliajf
  • 485
  • 7
  • 15