스위프트 화면 전환 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.
}
*/
}
'Swift > 기초&문법' 카테고리의 다른 글
swift tableview 간단한 테이블뷰 추가, 삭제 스위프트 (0) | 2018.11.08 |
---|---|
MyWebBrowser swift 스위프트 웹브라우저 앱 (0) | 2018.11.07 |
swift 스위프트 간단한 화면 전환 segue modaly (0) | 2018.11.02 |
꼼꼼한 재은씨의 스위프트 swift 실전편 api alamofire (0) | 2018.11.01 |
꼼꼼한 재은씨의 스위프트 swift 실전편 api 적용 앱 POST JSON (0) | 2018.10.31 |