SwitUI – Two navigationLink in a list

Try the following approach – the idea is to hide links in background of visible content and make them inactive for UI, but activated programmatically. Tested with Xcode 12 / iOS 14. struct MultiNavLink: View { var body: some View { return NavigationView { List { OneRowView() }.navigationBarTitle(“MultiNavLink”, displayMode: .inline) } } } struct OneRowView: … Read more

swiftui how to fetch core data values from Detail to Edit views

Here is a simplified version of your code Just paste this code into your project and call YourAppParent() in a body somewhere in your app as high up as possible since it creates the container. import SwiftUI import CoreData //Class to hold all the Persistence methods class CoreDataPersistence: ObservableObject{ //Use preview context in canvas/preview let … Read more

SwiftUI – how to avoid navigation hardcoded into the view?

The closure is all you need! struct ItemsView<Destination: View>: View { let items: [Item] let buildDestination: (Item) -> Destination var body: some View { NavigationView { List(items) { item in NavigationLink(destination: self.buildDestination(item)) { Text(item.id.uuidString) } } } } } I wrote a post about replacing the delegate pattern in SwiftUI with closures. https://swiftwithmajid.com/2019/11/06/the-power-of-closures-in-swiftui/

Using NavigationLink in Menu (SwiftUI)

NavigationLink should be inside NavigationView hierarchy. The Menu is outside navigation view, so put buttons inside menu which activate navigation link placed inside navigation view, eg. hidden in background. Here is a demo of possible approach (tested with Xcode 12.1 / iOS 14.1) struct DemoNavigateFromMenu: View { @State private var navigateTo = “” @State private … Read more