순서
- viewDidLoad -> 뷰가 나타나기 전 최초 1번만 실행
- viewWillAppear -> 뷰가 나타날 것이다
- viewDidAppear -> 뷰가 나타났다.
- viewWillDisAppear -> 뷰가 사라질 것이다.
- viewDidDisAppear -> 뷰가 사라졌다.
override func 안에 super.viewDid..를 붙여준다.
class 프로토콜인 UIViewController안에 들어있는 메서드를 이용하기 위해 super을 이용한다.
self와 super의 차이
self는 자기 자신의 인스턴스를 나타낸 키워드
super는 슈퍼클래스를 카리키는 키워드
modally: 뷰 위에 뷰가 올라간 구조
세로방향으로 전개
ex. alert 알람, 새로운 이메일 작성하기
dismiss를 이용하여 되돌아감
메소드는 UIViewController
@IBAction func present를_이용한_화면_전환(_ sender: UIButton) {
guard let SecondViewController = storyboard?.instantiateViewController(identifier: "SecondViewController")
as? SecondViewController else { return }
self.present(SecondViewController, animated: true, completion: nil)
}
@IBAction func dismiss를_이용하여_되돌아가기(_ sender: UIButton) {
self.presentingViewController?.dissmiss(animated: true)
}
스택 위에 뷰컨을 push하고 화면을 업데이트
가로방향으로 전개
pop을 이용하여 되돌아감
메소드는 UINavigationController
@IBAction func push를_이용한_화면_전환(_ sender: UIButton) {
guard let SecondViewController = storyboard?.instantiateViewController(identifier: "SecondViewController")
as? SecondViewController else { return }
self.navigationContorller?.pushViewCOntroller(SecondViewController, animated: true)
}
@IBAction func pop을_이용하여_되돌아가기(_ sender: UIButton) {
self.navigationController?.popViewController(animated: true)
}
@IBAction func popToRoot을_이용하여_처음으로_되돌아가기(_ sender: UIButton) {
self.navigationController?.popToRootViewController(animated: true)
}
오래달리기 위해 조금 열을 낮추기로 했다. 도움되지 않는다면 다시 열 내기로..