Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Unwind to ViewController in swift

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 384
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: