Wednesday, December 7, 2022
HomeiOS Developmentios - Why fullScreenCover at all times take first index from array?

ios – Why fullScreenCover at all times take first index from array?


Why fullScreenCover at all times take simply first index of an array?

That is some instance of code:

struct TestView: View {
    @State personal var isFullScreen: Bool = false
    var physique: some View {
        VStack{
            ForEach(0..<5, id:.self) { quantity in
                VStack{
                Textual content("(quantity)")
                    .background(.crimson)
                    .foregroundColor(.white)
                    .padding(20)
                    .onTapGesture {
                        isFullScreen.toggle()
                    }
                }
                .fullScreenCover(isPresented: $isFullScreen) {
                    test2View(title: quantity)
                }
            }
        }
    }
}

That is the code of test2View:

struct test2View: View {
    var title:Int
    var physique: some View {
        Textual content("(title)")
    }
}

Every time I click on on any quantity it at all times present simply 0, however after I make navigationLink as an alternative of fullScreenCover, it really works as anticipated, however navigationLink is not an answer for my drawback, I would like that to be fullScreenCover.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments