Use NavigationLink programmatically in SwiftUI

后端 未结 1 1024
别那么骄傲
别那么骄傲 2020-12-06 07:52

I\'m looking for a way to display a view in my WatchOS application \"one level in\" from the NavigationView on app startup if certain conditions are met.

I want the

相关标签:
1条回答
  • 2020-12-06 08:18

    I don't have any experience with watchOS, but I've used the the "isActive" variant of NavigationLink for similar app needs.

    In your initial view, define a @State var showOneLevelIn = false (or some other binding) and set that state var to true if you want the view to auto navigate to your second level. The label for the NavigationLink is an EmptyView() so it won't be visible in your initial view.

    NavigationLink(destination: OneLevelInView(), isActive: $showOneLevelIn, label: { EmptyView() })

    0 讨论(0)
提交回复
热议问题