I am trying to create similar controls as the ones below the date time picker in alarm app. It appears these controls are tableview cells. I want to have several tableview cells, but when a user clicks on it, the cell's segue will take them to the View Controller of the cell clicked.
In other words, if the user clicks on the Alarm App's "Repeat" cell, the segue will take the user to the "Repeat" View Controller.
If the user clicks "Label", the cell's segue will take the user to the "Label" View Controller.
So, is it possible to have this type of conditional segue?
Any samples/links in Swift would be appreciated. Thanks in advance.
in your didSelectItemAtIndexPath
call different segue identifier
if indexPath.row == 0 {
performSegueWithIdentifier("showPage1", sender: indexPath.row)
}
else if indexPath.row == 1 {
performSegueWithIdentifier("showPage2", sender: indexPath.row)
}
Then in your prepareForSegue
, check the condition.
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showPage1" {
// do something for page 1
}
else if segue.identifier == "showPage2" {
// do something for page 2
}
}
Your segue should drag from image below to destination controller
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With