Passing data between View Controllers using Segue

“Passing data to the destination Controller” when a segue is triggered will be achieved by overriding method prepareForSegue:sender:. Generally, you pass data and NOT the source view controller, to the destination view controller. “data” may be a certain aspect of your application “model”. It’s an object like “User”, or perhaps an array containing “User”, etc. … Read more

IOS7, Segue and storyboards – How to create without a button?

Delete the current segue. Attach the segue from the origin view controller to the destination (and then name it). Now, your button press method should look something like this: Objective-C: – (IBAction)validateLogin:(id)sender { // validate login if (validLogin) { [self performSegueWithIdentifier:@”mySegue” sender:sender]; } } Swift: @IBAction func validateLogin(sender: UIButton) { // validate login if validLogin … Read more

Conditionally start at different places in storyboard from AppDelegate

I’m surprised at some of the solutions being suggested here. There’s really no need for dummy navigation controllers in your storyboard, hiding views & firing segues on viewDidAppear: or any other hacks. If you don’t have the storyboard configured in your plist file, you must create both the window and the root view controller yourself … Read more

How to make a push segue when a UITableViewCell is selected

control drag From View Controller to View Controller You will need to give an identifier to your segue: Perform the segue: -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [self performSegueWithIdentifier:@”yourSegue” sender:self]; } Now here is the thing, this will just perform the segue, if you ever needed to pass some data to that view controller. Then you … Read more

Sending data with Segue with Swift

Set values from Any ViewController to a Second One using segues Like this: override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if(segue.identifier == “yourIdentifierInStoryboard”) { let yourNextViewController = (segue.destinationViewController as yourNextViewControllerClass) yourNextViewController.value = yourValue And in your yourNextViewController class. class yourNextViewControllerClass { var value:Int! // or whatever You can call this also programmatically: self.performSegueWithIdentifier(“yourIdentifierInStoryboard”, sender: self) … Read more

How to segue programmatically in iOS using Swift

If your segue exists in the storyboard with a segue identifier between your two views, you can just call it programmatically using: performSegue(withIdentifier: “mySegueID”, sender: nil) For older versions: performSegueWithIdentifier(“mySegueID”, sender: nil) You could also do: presentViewController(nextViewController, animated: true, completion: nil) Or if you are in a Navigation controller: self.navigationController?.pushViewController(nextViewController, animated: true)

Segue and Button programmatically swift

Create seuge Assign identifier and your button target @IBAction func button_clicked(_ sender: UIButton) { self.performSegue(withIdentifier: “segueToNext”, sender: self) } override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if segue.identifier == “segueToNext” { if let destination = segue.destination as? Modo1ViewController { destination.nomb = nombres // you can pass value to destination view controller // destination.nomb = … Read more

Passing data with unwind segue

Øyvind Hauge beat me to the same solution method, but as I had already started with a more detailed answer, I’ll add it as well. Let’s say your two view controllers are named as follows: Master/entry point: ViewController (vcA) Secondary view: ViewControllerB (vcB) You set up the segue from (vcA) -> (vcB) as you have … Read more

Creating a segue programmatically

I thought I would add another possibility. One of the things you can do is you can connect two scenes in a storyboard using a segue that is not attached to an action, and then programmatically trigger the segue inside your view controller. The way you do this, is that you have to drag from … Read more

tech