swiftui-navigationlink

Transition animation gone when presenting a NavigationLink in SwiftUI

喜你入骨 提交于 2020-08-10 23:11:28
问题 I have a List with NavigationLinks. List { ForEach(items, id: \.id) { item in NavigationLink(destination: ItemView(), tag: item.id, selection: self.$viewModel.selectedItemId) { Text("Some text") } } .onDelete(perform: delete) } .id(UUID()) And a corresponding ViewModel which stores the selected item's id. class ViewModel: ObservableObject { @Published var selectedItemId: String? { didSet { if let itemId = selectedItemId { ... } } } ... } The problem is that when I use NavigationLink

Transition animation gone when presenting a NavigationLink in SwiftUI

余生颓废 提交于 2020-08-10 23:11:22
问题 I have a List with NavigationLinks. List { ForEach(items, id: \.id) { item in NavigationLink(destination: ItemView(), tag: item.id, selection: self.$viewModel.selectedItemId) { Text("Some text") } } .onDelete(perform: delete) } .id(UUID()) And a corresponding ViewModel which stores the selected item's id. class ViewModel: ObservableObject { @Published var selectedItemId: String? { didSet { if let itemId = selectedItemId { ... } } } ... } The problem is that when I use NavigationLink

Transition animation gone when presenting a NavigationLink in SwiftUI

左心房为你撑大大i 提交于 2020-08-10 23:08:12
问题 I have a List with NavigationLinks. List { ForEach(items, id: \.id) { item in NavigationLink(destination: ItemView(), tag: item.id, selection: self.$viewModel.selectedItemId) { Text("Some text") } } .onDelete(perform: delete) } .id(UUID()) And a corresponding ViewModel which stores the selected item's id. class ViewModel: ObservableObject { @Published var selectedItemId: String? { didSet { if let itemId = selectedItemId { ... } } } ... } The problem is that when I use NavigationLink

SwiftUI deep linking with NavigationLink inside List onAppear with tag: and selection: doesn't activate link

你。 提交于 2020-06-29 04:30:07
问题 Trying to build deep linking into a list of NavigationList items; I will be reading a value on the SwiftUI view's .onAppear and based on that value, navigate to a specific cell. There are three issues that come up with different setups I have tried: (1) with the below code, navigation doesn't happen at all, (2) if it does navigate, it will immediately pop back, (3) if programmatic navigation works and it doesn't pop back, the manual navigation doesn't work. I have tried this with a Binding

SwiftUI NavigationLink immediately navigates back

六眼飞鱼酱① 提交于 2020-06-27 17:58:05
问题 I am using SwiftUI to create NavigationLinks from rows to detail views in a NavigationView (similar to what is being done in the tutorial https://developer.apple.com/tutorials/swiftui/building-lists-and-navigation). However, when I test in my app, the NavgiationLink immediately navigates back from the detail view to the previous view after being tapped (the detail view only shows up for only a second). Here's the code: struct ItemsView: View { var body: some View { NavigationView { VStack {

how to make the code simpler and more reusable for navigation links with multi dimension dictionary in swiftui?

你离开我真会死。 提交于 2020-06-23 14:16:41
问题 I have a multi-level dictionary that I need use to build navigation links. Now I have a 2-level depth dictionary: let multiDimDict: [String: [[String: [String]]]] = ["A": [["A1": ["A11", "A12"]], ["A2": ["A21", "A22"]]], "B": [["B1": ["B11", "B12"]], ["B2": ["B21", "B22"]]] ] I can build the navigation view with all navigation links. However, I feel that I am somehow repeating some code in building navigation links. The question is, if I have a many-level dictionary, say 10-level, I don't

SwiftUI NavigationLink programmatic navigation inside onAppear immediately navigates back/pops the view when using a dictionary [String:Binding<Bool>]

白昼怎懂夜的黑 提交于 2020-06-23 11:23:27
问题 I want to programmatically be able to navigate to a link within a List of NavigationLinks when the view appears (building deep linking from push notification). I have a string -> Bool dictionary which is bound to a custom Binding<Bool> inside my view. When the view appears, I set the bool property, navigation happens, however, it immediately pops back. I followed the answer in SwiftUI NavigationLink immediately navigates back and made sure that each item in the List has a unique identifier,