-1

This is a really weird issue that I haven't been able to resolve.

It happens only on iOS 15 and only the 1st time I try to open this specific NavigationLink.

I have 3 SwiftUI Views:

  • ContentView (entry point)
  • DetailView
  • ItemView

ContentView is a list of DetailViews and in detail views there can be any amount if ItemViews.

I have an ObservableObject with a Published property count, that is only accessed from ContentView. In ItemView I have function that's triggered by onAppear, that updates count in the ObservedObject.

When I open an ItemView for the first time after opening the App, it moves to the view but immediately goes back to DetailView. It doesn't happen, when I open it again, even though count is updated again.

I have spent a lot of time debugging this issue, but I'm out of ideas. I have tried reproducing it in a Swift Playground, but everything I've tried there seems to work as expected.

I hope someone has an idea on how I can resolve this issue, I would be most grateful!

Adam
  • 173
  • 9

1 Answers1

0

If you are using a nav link, I would highly suggest using a custom one instead. I can't understand why this is only happening in ios 15 for you, but I have had a similar bugs with the same views/logic in previous OS versions.

Trevor
  • 580
  • 5
  • 16
  • Yes, I'm using SwiftUI's `NavigationLink`, what do you mean by "custom one"? I pass a custom view, not a String. – Adam Oct 18 '21 at 09:35
  • 1
    [link](https://www.youtube.com/watch?v=XGXWC68Yb_o&t=1220s&ab_channel=SwiftfulThinking) This video should fix your issue. It shows the flaws of navlink and how to create your own custom navlink using ontapgesture, a loading view, and segue. – Trevor Oct 18 '21 at 19:19