์ค์๊ฐ ๊ฒ์ ๊ธฐ๋ฅ
- ๊ฒ์ํ๊ณ ์๋ ๋จ์ด ๋ฐฐ์ด
- ๊ฒ์ ๋ฒํผ ๋๋ฅด๊ฑฐ๋ ๊ธ์ ๋ณ๊ฒฝ ๋์ ๋ ๊ฒ์ ์ ๋จ์ด ํฌํจํ๊ณ ์๋ list ์์ searchlist์ ์ถ๊ฐํ๊ธฐ
- ๊ฒ์ ๋ ์ ์์ ์ข์์ ๋๋ฅด๋ ๊ธฐ๋ฅ
→ ์ด๋ ๊ฒ ๊ตฌํ ํ๋ฉด ์๋ณธ๋ฐ์ดํฐ์๋ ์ข์์ ๋ฐ์ ์๋์ ๊ฒ์ํ๋ฉด ์์ด์ง
ํด๊ฒฐ๋ฐฉ๋ฒ
- ์ํ ํ์ดํ ๊ฐ์ ธ์ค๊ธฐ
- ์๋ณธ ๋ฐฐ์ด(list)์์ ๊ฐ์ title์ ๋ฐ์ดํฐ ์กฐํํด์ ๋ณ๊ฒฝํ๊ธฐ
- item์ ๋ฐ๋ณต๋ฌธ์ฉ ๋ณ์์ ์ธ๋ฑ์ค ๊ฐ์ ธ์ฌ ์ ์์.
-
- item์ด๋ index ๋ ๋ค ๊ฐ์ ธ์์ ์๋ณธ์ธ list์์ ๋ฐ์ดํฐ ์์
-
ํ ์คํธํ๋ ํ๋ ์ด์ค ํ๋ ๋ฒ๊ทธ ์ ๊ฑฐ
- ์๋ ๋ก์ง ์ฒ๋ผ ํ ์คํธ ํ๋ ํ ์คํธ ๋ด์ฉ์ผ๋ก๋ง ํ๋ ์ด์ค ํ๋ ui ์ฒ๋ฆฌํ๋ฉด ์ฌ์ฉ์๊ฐ placeholder๋ ๊ฐ์ ๋ด์ฉ ์ ๋ ฅํ์๋ ํ์์ผ๋ก ๋ณํด๋ฒ๋ฆฌ๋ ๋ฒ๊ทธ ์๊ธธ ์ ์์.
- ์๋์ฒ๋ผ ํ ์คํธ ์ปฌ๋ฌ ๊ธฐ์ค์ผ๋ก ํ๋จํ๋ฉด ์ค๋ฅ X
์ฑ์ ์ฒซ ํ๋ฉด ์ค์ ํ๊ธฐ
์ฑ์ ํค๊ฒ ๋๋ฉด ๊ฐ์ฅ ์ฒ์ AppDelegate ์ฝ๋๋ค ๋์๊ฐ ํ SceneDelegate ์ฝ๋ ์คํ๋จ
SceneDelegate.swift
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let _ = (scene as? UIWindowScene) else { return }
let isLaunched = UserDefaults.standard.bool(forKey: "isLaunched")
//๋ง์ฝ ์ ์ ๊ฐ ์ฒซ ์คํ์ด๋ผ๋ฉด
if isLaunched == false {
let sb = UIStoryboard(name: "main", bundle: nil)
let vc = sb.instantiateViewController(withIdentifier: "FirstViewController") as! FirstViewController
window?.rootViewController = vc
} else {
let sb = UIStoryboard(name: "main", bundle: nil)
let vc = sb.instantiateViewController(withIdentifier: "LibraryViewController") as! LibraryCollectionViewController
let nav = UINavigationController(rootViewController: vc) window?.rootViewController = vc
}
window?.makeKeyAndVisible()
}
- ๋ง์ฝ ์ ์ ๊ฐ ์ฒ์ ์ฑ์ ์คํํ๋ค๋ฉด FirstViewController๋ฅผ ์ฒซ ํ๋ฉด์ผ๋ก
- ์ฒ์ ์คํ์ด ์๋๋ผ๋ฉด Library View Controller๋ฅผ ์ฒซ ํ๋ฉด์ผ๋ก
- isLaunched ์ ์ ๋ํด์ธ ๊ฐ true๋ก ์ง์ ํ๋ ์ง์ ์ ์จ๋ณด๋ฉ ํ๋ฉด ์์ํ์ ๋ ๋ฐ๊ฟ์ง or ์จ๋ณด๋ฉ ๋ค๋ณด๊ณ ํ ๊ฑด์ง or๋ฉ์ธํ๋ฉด ๋จ๊ณ ํ ๊ฑด์ง ๋ฑ์์ ๋ฐ๋ผ ๋ก์ง์ด ๋ฌ๋ผ์ง
ํ๋ก์ฐ ์ค๊ฐ์ ๋ฃจํธ๋ทฐ ์ปจํธ๋กค๋ฌ ๊ต์ฒด ํ๋ ์ฝ๋
@IBAction func startButtonClicked(_ sender: Any) {
UserDefaults.standard.set(true, forKey: "isLaunched")
let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
let sceneDelegate = windowScene?.delegate as? SceneDelegate
let sb = UIStoryboard(name: "Main", bundle: nil)
let vc = sb.instantiateViewController(withIdentifier: "LibraryCollectionViewController") as! LibraryCollectionViewController
let nav = UINavigationController(rootViewController: vc)
sceneDelegate?.window?.rootViewController = nav
sceneDelegate?.window?.makeKeyAndVisible()
}
์์ฝ๋์ UIApplication์ AppDelegate์ ์๋ ์ .
UIApplication
'SeSAC' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[iOS] TIL_230808 (0) | 2023.08.09 |
---|---|
[iOS] TIL_230807 (0) | 2023.08.09 |
[iOS] TIL_230803 (0) | 2023.08.06 |
[iOS] TIL_230802 (0) | 2023.08.05 |
[iOS] TIL_230801 (0) | 2023.08.03 |