Navigation Controller를 이용한 화면 전환
push - pop 방식
push
@IBAction func btnPushWithCode(_ sender: Any) {
guard let viewController = self.storyboard?.instantiateViewController(identifier: "PushWithCodeViewController") else { return }
self.navigationController?.pushViewController(viewController, animated: true)
}
pop
@IBAction func btnBack(_ sender: UIButton) {
self.navigationController?.popViewController(animated: true)
}
View Controller에서 다른 View Controller를 호출하여 전환
present - dismiss 방식
present
@IBAction func btnPresentWithCode(_ sender: Any) {
guard let viewController = self.storyboard?.instantiateViewController(identifier: "PresentWithCodeViewController") else { return } // PresentWithCodeViewController 라는 identifier를 가진 화면을 불러올거야
viewController.modalPresentationStyle = .fullScreen // present 방식에 대한…
self.present(viewController, animated: true, completion: nil) // completion 뒤의 closure 문이 실행됨
}
dismiss
@IBAction func btnBack(_ sender: UIButton) {
self.presentingViewController?.dismiss(animated: true, completion: nil) // completion 뒤의 closure 문이 실행됨
}