-1

NOTE: I have reported it to apple. However, the question is, "Is there a workaround/fix for this?" My concern is this will be missed by apple and I want to have a workaround ready if Apple does NOT fix it for their final release.

Using the new navigationDestination and NavigationPath functions previously on iOS 16 everything has been working fine using a custom back button, which calls path.removeLast().

However, if we try this on iOS 17 BETA 5, the screen being removed flashes white.

Also, how can I raise this as a bug with Apple, so they can fix it before the release of iOS 17.

You can try this code as an example (NOTE THE WHITE FLASH ON REMOVE LAST):

struct DetailView: View {
    @Binding var path: NavigationPath

    var body: some View {
        ZStack {
            Color.black
            VStack(alignment: .center) {
                Spacer()
                Button(action: {
                    path.removeLast()
                }, label: {
                    Text("BACK")
                })
                Spacer()
            }
        }
    }
}

struct ParentView: View {
    @State var path: NavigationPath = .init()

    var body: some View {
        NavigationStack(path: $path) {
            ZStack {
                Color.red
                VStack(alignment: .center) {
                    Spacer()
                    Button(action: {
                        path.append("TEST")
                    }, label: {
                        Text("FORWARD")
                    })
                    Spacer()
                }
            }
            .navigationDestination(for: String.self) { _ in
                DetailView(path: $path)
            }
        }
    }
}

Is there a workaround/fix for this?

Peter Suwara
  • 781
  • 10
  • 16
  • This is a beta and you are a beta tester. If you think you've found a bug, report it to Apple. – matt Aug 15 '23 at 00:13
  • https://developer.apple.com/bug-reporting/ – jnpdx Aug 15 '23 at 01:33
  • Hey guys, I have reported it to apple. However, the question is, "Is there a workaround/fix for this?" My concern is this will be missed by apple and I want to have a workaround ready if Apple does NOT fix it for their final release. – Peter Suwara Aug 15 '23 at 03:05
  • Have you tried using your NavigationPath inside an ObservableObject? https://developer.apple.com/documentation/swiftui/navigationpath – Lawrence Gimenez Aug 15 '23 at 03:58
  • @LawrenceGimenez yes, the issue happens in ALL cases of using a navigation path with a custom back button on the navigation path. Using the Built in Back button works, but it doesn't actually update the NavigationPath, so the stack gets out of sync with the actual views. – Peter Suwara Aug 15 '23 at 07:15
  • I see, I believe there is no workaround for this as of now. No idea, why everyone was hostile to you. – Lawrence Gimenez Aug 15 '23 at 11:48
  • Thanks @LawrenceGimenez. I think people missed reading the entire text of the post. :) – Peter Suwara Aug 18 '23 at 02:01

0 Answers0