반응형
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
- JSX
- bit
- nodeJS
- component
- array
- leetcode
- css
- priority_queue
- Navigation
- server
- Props
- React
- treenode
- map
- node.js
- Context
- c++
- MySQL
- Callback
- UE5
- DP
- routes
- axios
- event
- state
- count
- route
- 비트연산
- BinaryTree
- queue
Archives
- Today
- Total
우사미 코딩
NavigationStack에 Path 설정하기 본문
반응형
struct ContentView: View {
@StateObject var carStore: CarStore = CarStore(cars: carData)
@State private var path = NavigationPath()
var body: some View {
NavigationStack(path: $path) {
List {
ForEach(0..<carStore.cars.count, id: \.self) { i in
NavigationLink(value: i) {
ListCell(car: carStore.cars[i])
}
}
}
.navigationDestination(for: Int.self) { i in
CarDetail(selectedCar: carStore.cars[i])
}
.navigationTitle("Car List")
}
}
}
NavigationStack 및 NavigationPath는 SwiftUI에서 iOS 16 및 macOS 13 Ventura 이상에서 도입된 새로운 네비게이션 시스템입니다. 이는 기존의 NavigationView와 NavigationLink를 대체하거나 보완하는 역할을 합니다. 이 새로운 네비게이션 시스템은 더 복잡한 네비게이션 경로를 처리하고, 상태를 관리하며, 프로그램적으로 네비게이션을 제어할 수 있는 더 많은 유연성을 제공합니다.
반응형
'Programming (C++) > XCode, SwiftUI' 카테고리의 다른 글
동기 await, async (0) | 2024.07.10 |
---|---|
Environment, ObservableObject (0) | 2024.07.08 |
하위 View에 프로퍼티 전달하기 (바인딩) (0) | 2024.07.08 |
동적으로 Stack 변환하기 (0) | 2024.07.08 |
Comments