0

i have an error when I close a view in swift ui. I have this the video. The view is opening and closing alone like a look.

This is my code for opening the detail view.

VStack(alignment: .leading) {
                                        Text("Les derniers articles")
                                              .font(.title)
                                              .fontWeight(.bold)
                                            .padding(.leading)
                                        ForEach(observed.articles) {i in
                                        NavigationLink(destination: ArticleDetailScreen(

                                            id_open: i.id,
                                            article_name_open: i.article_name,
                                            article_category_open: i.article_category,
                                            article_description_open: i.article_description,
                                            article_header_URL_image_open: i.article_header_URL_image,
                                            content_open: i.content
                                        )) {
                                                                MainArticleElementView(
                                                                    viewType: "shor",
                                                                    id: i.id,
                                                                        article_name: i.article_name,
                                                                        article_category: i.article_category,
                                                                        article_description: i.article_description,
                                                                        article_header_URL_image: i.article_header_URL_image,
                                                                        content: i.content
                                                                        )
                                                }.buttonStyle(PlainButtonStyle())
                                        }.frame(minWidth: 0, maxWidth: .infinity, alignment: .center)
                                    }.background(Color(UIColor.systemBackground)).cornerRadius(20)

and the code of my detail view :


@Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>

{...}

 var body: some View {

ZStack(alignment: .topLeading) {
            ScrollView {
            VStack(alignment: .leading) {

{...}

Button(action: {
                self.presentationMode.wrappedValue.dismiss()

            }) {
                Image(systemName: "chevron.left.circle.fill")

                       .resizable()
                       .scaledToFit()
                       .frame(width: 30, height: 30)

                       .foregroundColor(Color(UIColor.secondarySystemBackground))
                       .background(Color(UIColor.secondaryLabel))
                       .clipShape(Circle())
                       .padding().padding(.top, 50)
            }

If you need any idea it's will be so grate. Thank you so much

Mathieu Cloart
  • 121
  • 2
  • 11

1 Answers1

0

Are you getting the error in the simulator running iOS 13.3? You could also try using an alternative to NavigationLink using the isActive option.

P. Ent
  • 1,654
  • 1
  • 12
  • 22