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

I did some searching but didn't understand the answer and I hope, I can ask the question again and

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1736115164a3861290.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信