tags : #ios #ui #uikit #ํ๋ฉด์ด๋ #view #์ฝ๋
- ์ฝ๋๋ฅผ ํตํด (๋์ด๊ฐ ํ๋ฉด์ ์ฝ๋ ํ์ผ์ด ์กด์ฌํด์ผ ๊ฐ๋ฅ)
let firstVC = FirstViewController()
firstVC.modalPresentationStyle = .fullScreen
firstVC.someString = "๋ด๋ถ ๋ณ์๋ก ๋ฐ์ดํฐ ์ ๋ฌ ๊ฐ๋ฅ"
firstVC.mailLabel.text = "์ฐ๊ฒฐํ๋ฉด์ด ์คํ ๋ฆฌ๋ณด๋๋ก ๋ง๋ค์ด์ก์ผ๋ฉด ์ด ์ค์ ๋ฐฉ์์ ๋ถ๊ฐ๋ฅ"
present(firstVC, animated: true, completion: nil)
- ์ฝ๋๋ก ๋ง๋ค์์ ๋๋ง ์์ฒ๋ผ ์ธ์คํด์ค๋ฅผ ๋ง๋๋ ๊ฒ์ด ๊ฐ๋ฅํ๋ค.
- view์์ ๋ชจ๋ UI๋ค์ด ๋ฉ๋ชจ๋ฆฌ์ ์ฌ๋ผ๊ฐ ์ ์๊ธฐ ๋๋ฌธ
- (storyboard๋ก ๋ง๋ ํ๋ฉด์ UI๋ ํ ์์ญ์ ์ฌ๋ผ๊ฐ๋ค.)
- modalPresentationStyle ์ ์ด๋ค ์คํ์ผ๋ก ํ๋ฉด์ ๋์ธ ์ง ์ ํ๋ค.
- firstVC.someString ๋ณ์๋ฅผ ์ต์ ๋๋ก ๋ง๋ค์ด์ ๋ฐ์ดํฐ๋ฅผ ๋ฐ์ ์ ์๋ค.
- ๋์๊ฐ๋๋ dismiss ์ฌ์ฉ
@objc func backButtonTapped() {
dismiss(animated: true completion: nil)
}
- ์คํ ๋ฆฌ๋ณด๋๋ก ๋ง๋ ํ๋ฉด์ผ๋ก ๋์ด๊ฐ ๋
if let secondVC = storyboard?.instantiateViewController(withIdentifier: "secondVC") as? SecondViewController {
secondVC.someString = "๋ด๋ถ ๋ณ์๋ก ๋ฐ์ดํฐ ์ ๋ฌ ๊ฐ๋ฅ"
// seconeVC.mailLabel.text = "์ฐ๊ฒฐํ๋ฉด์ด ์คํ ๋ฆฌ๋ณด๋๋ก ๋ง๋ค์ด์ก์ผ๋ฉด ์ด ์ค์ ๋ฐฉ์์ ๋ถ๊ฐ๋ฅ"
present(secondVC, animated: true completion: nil)
}
- guard let์ ์จ๋ ๋๊ณ , if let ๋์ let๊ณผ as!๋ฅผ ์ฌ์ฉํด์ ์งํํด๋ ๋๋ค. (์คํ ๋ฆฌ๋ณด๋๊ฐ ์๋ ๊ฒฝ์ฐ๊ฐ ๊ฑฐ์ ์์ผ๋ฏ๋ก...)
- UIViewController์ ์ ์ฅ๋ storyboard๋ผ๋ ๋ณ์๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ด๋ค.
- withIdentifier์ ๋ค์ด๊ฐ๋ string์ ์ฐ๊ฒฐํ ์คํ ๋ฆฌ๋ณด๋์ id์ ์ผ์นํด์ผ ํ๋ค.(๋ณ๋ ์ค์ ํ์)
- ์ฌ๊ธฐ์๋ "secondVC"
- ๋ฐ์์จ ์คํ ๋ฆฌ๋ณด๋๋ฅผ SecondViewController ํ์ ์ผ๋ก ์บ์คํ ํด์ฃผ๋ ๊ฒ์ด๋ค.
[[note_list_ios]] [[segue]]