Reputation: 389
I use this simple code to segue:
self.performSegue(withIdentifier: "showSeqTwo", sender: self)
After this segue, I need a timer in the controller to launch automatically. The problem is that normally the timer is supposed to be launched by pressing a play button, and then paused and relaunched at will. The user can also swipe to this controller, in which case the timer should not be triggered. Can I send some kind of a signal with this particular segue to programmatically "push" the button and launch the timer?
Upvotes: 0
Views: 55
Reputation: 126
You can send a variable that is read in the viewDidLoad() function of the second viewController, and determine if the play button should activate.
Add a function to the bottom of your first viewController like this:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showSeqTwo" {
let destination = segue.destination as! NameOfSecondViewControllerClass
destination.segueFlag = 1
}
}
Inside the second viewController, add the following variable into the class:
var segueFlag = 0
Inside the viewDidLoad() of the second viewController, add the following code
if segueFlag == 1 {
// Add function to start play button here
}
Upvotes: 1