iOS/STUDY

[iOS] Navigation Interface 구현하기

느리님 2021. 2. 5. 16:05

새로운 ViewController 생성

새로운 viewController 파일 생성

  1. command + N (새로운 파일 생성) 
  2. cocoa touch file 생성
  3. 처음 생성했을때 상속이 UIViewController가 아니었으므로 바꿔주기

ViewController 와 파일 연결하기

Navigation Controller 생성하기

ViewController 연결하기

- 새로운 버튼 생성 후에 control 키를 누르고 화면으로 이동 후 

   Action Segue 에서 Show 선택

Back 생성됨

POP 버튼 만들어서 이전 화면으로 돌아가기

- 왜인지 모르겠는데 새로 cocoa touch 파일을 생성하면 빈화면이 생성된다..

import UIKit

class SecondViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    
    @IBAction func popToOver() {
        self.navigationController?.popViewController(animated: true)
    }
}

- SecondViewController.swift 코드

- popToOver과 POP 버튼 연결하기