Notice
														
												
											
												
												
													Recent Posts
													
											
												
												
													Recent Comments
													
											
												
												
													Link
													
											
									| 일 | 월 | 화 | 수 | 목 | 금 | 토 | 
|---|---|---|---|---|---|---|
| 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 | 
													Tags
													
											
												
												- PyQt5
- 함수
- 다이어트
- 유니티
- Linux
- urllib
- flutter
- Unity
- 라즈베리파이
- IOS
- ASP
- swift
- 리눅스
- javascript
- GIT
- python
- MySQL
- PyQt
- port
- sqlite
- PER
- mssql
- tensorflow
- ubuntu
- MS-SQL
- pandas
- Excel
- node.js
- 날짜
- 맛집
													Archives
													
											
											
											
											아미(아름다운미소)
Swift 네비게이션 컨트롤러를 이용한 화면 전환 본문
Swift 네비게이션 컨트롤러를 이용한 화면 전환
- 네비게이션 컨트롤러는 뷰 컨트롤러의 특별한 종류로 계층적인 성격을 띠는 콘텐츠 구조를 관리하기 위한 컨트롤러 입니다.(내비게이션 바가 내장되어 있습니다.)
- 이 컨트롤러가 제어하는 모든 뷰 컨트롤러에 내비게이션 바를 생성하는 특징이 있습니다.
- 루트뷰 컨트롤러는 내비게이션 컨트롤러에 직접 연결된 컨트롤러이므로 화면 UI상단에 내비게이션 바가 표시됩니다.
- 내비게이션 컨트롤러는 화면에 현재 표시되고 있는 뷰 컨트롤러들을 내비게이션 스택을 이용하여 관리합니다.
- 내비게이션 컨트롤러 최상위 뷰컨트롤러는(마지막컨트롤러), 최하위 컨트롤러는(루트뷰 컨트롤러)
import UIKit
class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    @IBAction func moveByNavi(_ sender: Any) {
        
        // 
        guard let uvc = self.storyboard?.instantiateViewController(withIdentifier: "SecondVc") else {
            return
        }
        self.navigationController?.pushViewController(uvc, animated: true)
    }
    @IBAction func movePresent(_ sender: Any) {
        guard let uvc = self.storyboard?.instantiateViewController(withIdentifier: "SecondVc") else {
            return
        }
        self.present(uvc, animated: true)
    }
}
최상위 뷰 컨트롤러에서 제거할 때는 popViewController(animated:) -> 이전화면으로 돌아올때 사용
import UIKit
class SecondViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    @IBAction func back(_ sender: Any) {
        self.presentingViewController?.dismiss(animated: true)
        
    }
    @IBAction func back2(_ sender: Any) {
        self.navigationController?.popViewController(animated: true)
    }
}
'랭귀지 > SWIFT' 카테고리의 다른 글
| 스위프트 - navigation에서 back button을 숨기는 방법 (0) | 2018.06.01 | 
|---|---|
| [iOS] viewDidLoad에서 다른 뷰 컨트롤러로 이동 (0) | 2018.05.31 | 
| UISwitch의 사이즈를 조정하는 방법 (0) | 2018.05.28 | 
| UISwitch 기본 색상 (orange)을 변경하는 방법 (0) | 2018.05.27 | 
| [iOS/Swift 4.0] TableView Row 클릭 이벤트 작동안할 때 (0) | 2018.05.25 | 
			  Comments