swift 如何在iOS 16中使用navigationLink

bihw5rsg  于 2023-03-11  发布在  Swift
关注(0)|答案(1)|浏览(714)

我收到错误“init(destination:isActive:label:)”已在iOS 16.0中弃用:在导航堆栈或导航拆分视图中使用导航链接(值:标签:)

.background(
            NavigationLink(destination: DetailLoadingView(coin: $selectedCoin), isActive: $showDetailView, label: {
                EmptyView()
            })
        )
20jt8wwn

20jt8wwn1#

变更:

  1. NavigationView{}NavigationStack{}
  2. NavigationLink(){}NavigationDestination
    示例:
NavigationStack{        
...
.navigationDestination(isPresented: $isSame){
                        BackgroundView() //if $isSame = true, navigate to BackgroundView()
    }
}

相关问题