스위프트 화면 전환 present dismiss push pop segue modal swift






//

//  ViewController.swift

//  PresentScreen

//

//  Created by stayfoolish on 06/11/2018.

//  Copyright © 2018 stayfoolish. All rights reserved.

//


import UIKit


class ViewController: UIViewController {


    @IBOutlet var nameTextField: UITextField!

    

    override func viewDidLoad() {

        super.viewDidLoad()

        // Do any additional setup after loading the view, typically from a nib.

    }


    @IBAction func presentMenuClicked(_ sender: UIButton) {

        if let menuScreen = self.storyboard?.instantiateViewController(withIdentifier: "Menu"){

            menuScreen.modalTransitionStyle = .coverVertical

            self.present(menuScreen, animated: true, completion: nil)

        }


    }

    

    @IBAction func moveToMenuClicked(_ sender: UIBarButtonItem) {

        

        if let menuScreen =  self.storyboard?.instantiateViewController(withIdentifier: "Menu"){

            self.navigationController?.pushViewController(menuScreen, animated: true)

        }

    }

    

    @IBAction func manualMenuClicked(_ sender: UIButton) {

        self.performSegue(withIdentifier: "ManualMenu", sender: self)

    }

    

    @IBAction func unwindFromMenu(segue: UIStoryboardSegue){

        NSLog("unwindFromMenu 호출됨")

    }

    

    @IBAction func menuClicked(_ sender: UIButton) {

         let menuScreen = storyboard!.instantiateViewController(withIdentifier: "Menu") as? MenuViewController

        navigationController?.pushViewController(menuScreen!, animated: true)

        menuScreen?.paramData = self.nameTextField.text!

    }

    

    

}




//

//  MenuViewController.swift

//  PresentScreen

//

//  Created by stayfoolish on 06/11/2018.

//  Copyright © 2018 stayfoolish. All rights reserved.

//


import UIKit


class MenuViewController: UIViewController {


    @IBOutlet var nameLabel: UILabel!

    

    var paramData = ""

    

    override func viewDidLoad() {

        super.viewDidLoad()

        // Do any additional setup after loading the view.j

        nameLabel.text = paramData

    }

    

    override func didReceiveMemoryWarning() {

        super.didReceiveMemoryWarning()

    }


    @IBAction func backClicked(_ sender: UIButton) {

       self.presentingViewController?.dismiss(animated: true, completion: nil)

    }

    @IBAction func backClickedPop(_ sender: UIButton) {

        self.navigationController?.popViewController(animated: true)

    }

    /*

    // MARK: - Navigation


    // In a storyboard-based application, you will often want to do a little preparation before navigation

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

        // Get the new view controller using segue.destination.

        // Pass the selected object to the new view controller.

    }

    */


}




+ Recent posts