最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

swiftui navigationlink - NavigationDestination "in" variable as Binding in destination view not possible, why?

programmeradmin8浏览0评论

I did some searching but didn't understand the answer and I hope, I can ask the question again and get some help to find a solution.

I have a LazyVGrid with a NavigationLink inside and I would like to do that.

@State private var trainings = [TrainingData]()

LazyVGrid(columns: columns, spacing: columnVSpace) {
                        
    ForEach(trainings, id: \.id) {training in
    
        NavigationLink(value: training) {
        
            TrainingItemViewiPad(training: $training, trainings: $trainings) // => here is the issue, please see screenshot
        }
    }
}

struct TrainingItemViewiPad: View {
    
   @Binding var training: TrainingData
   @Binding var trainings: [TrainingData]

}

Here is my navigationDestination with the same issue.

.navigationDestination(for: TrainingData.self) { training in
    TrainingDetailViewiPad(training: $training, trainings: $trainings) // => here is the issue, please see screenshot
}

struct TrainingDetailViewiPad: View {
    
    @Binding var training: TrainingData

}

Is there a way to use Binding as shown?

Many thanks advance, Sven

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论