To Use Unwind Segues in swift please follow the steps:-
1- Create two ViewController using storyBoard
2- Create a segue from FirstViewControleller to secondViewController
3- Write a function in FirstViewController like this
@IBAction func unwindSegueFromSecondViewController( segue : UIStoryboardSegue)
    {
        if mysegue.identifier == "unwindSegue"
        {
            let controller = mysegue.sourceViewController as! secondViewController           
           myTextLabel?.text = controller.myText           
        }
    }
4- Call unwindSegue from the secondViewController
class secondViewController: UIViewController {
    
var myText:String!
        override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    @IBAction func buttonPopTapped(sender: AnyObject?)
    {
         myText = "my text to print"
        self.performSegueWithIdentifier("unwindSegue", sender: nil)
        
    }
        
}
5- Select the ViewCotroller and Drag from viewcontroller name to exit button that appear on top of the viewController.
6- select the this segue and set the identifier "unwindSegue"
To Use Unwind Segues in swift please follow the steps:-
1- Create two ViewController using storyBoard
2- Create a segue from FirstViewControleller to secondViewController
3- Write a function in FirstViewController like this
@IBAction func unwindSegueFromSecondViewController( segue : UIStoryboardSegue)
    {
        if mysegue.identifier == "unwindSegue"
        {
            let controller = mysegue.sourceViewController as! secondViewController           
           myTextLabel?.text = controller.myText           
        }
    }
4- Call unwindSegue from the secondViewController
class secondViewController: UIViewController {
    
var myText:String!
        override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    @IBAction func buttonPopTapped(sender: AnyObject?)
    {
         myText = "my text to print"
        self.performSegueWithIdentifier("unwindSegue", sender: nil)
        
    }
        
}
5- Select the ViewCotroller and Drag from viewcontroller name to exit button that appear on top of the viewController.
6- select the this segue and set the identifier "unwindSegue"
                       
                    
0 Comment(s)