티스토리 뷰

* push는 navigation controller가 연결된 상태에서만 작동 *

1. segue로 push

 

전환 : 원래 화면에 있는 Button을 끌어다가 이동할 VC에 'Show'로 연결

뒤로가기 : 이동한 화면 속 Button에 해당 코드 작성

self.navigationController?.popViewController(animated: true)
// 평상시

self.navigationController?.popToRootViewController(animated: true)
// Tip: 네비게이션 컨트롤러로 연결된 화면에서 맨 첫번째 화면으로 뒤돌아가고 싶을 때

 

 

2. code로 push

 

전환 : 이동할 VC의 속성 인스펙터로 가서 storyboard ID 설정 (ex. secondVC), 원래 화면에 있는 Button에 해당 코드 작성

guard let secondVC = self.storyboard?.instantiateViewController(withIdentifier: "secondVC") else { return }
        self.navigationController?.pushViewController(secondVC, animated: true)

뒤로가기 : 이동한 화면 속 Button에 해당 코드 작성

 

self.navigationController?.popViewController(animated: true)
// 평상시

self.navigationController?.popToRootViewController(animated: true)
// Tip: 네비게이션 컨트롤러로 연결된 화면에서 맨 첫번째 화면으로 뒤돌아가고 싶을 때

 

 

3. segue로 present

전환 : 원래 화면에 있는 Button을 끌어다가 이동할 VC에 'Present Modally'로 연결

뒤로가기 : 이동한 화면 속 Button에 해당 코드 작성

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

// 혹은

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

 

4. code로 present

전환 : 이동할 VC의 속성 인스펙터로 가서 storyboard ID 설정 (ex. secondVC), 원래 화면에 있는 Button에 해당 코드 작성

guard let secondVC = self.storyboard?.instantiateViewController(withIdentifier: "secondVC") else { return }
        self.present(secondVC, animated: true, completion: nil)

뒤로가기 : 이동할 화면 속 Button에 해당 코드 작성

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

// 혹은

self.presentingViewController?.dismiss(animated: true, completion: nil)
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
글 보관함