5

I have a simple use case where a screen pushes another screen using the NavigationLink. There is a strange behaviour iOS 14.5 where the pushed screen is popped just after being pushed.

Code:

NavigationLink(destination: EmptyView()) { EmptyView()} 

I manage to create a sample app where I reproduce it. I believe the cause is the presence of @Environment(\.presentationMode) that seem to re-create the view and it causes the pushed view to be popped.

The exact same code works fine in Xcode 12 / iOS 14.4

Lal Krishna
  • 15,485
  • 6
  • 64
  • 84

1 Answers1

4

I was stuck in this since last week. To fix, I simply added this to my view containing my existing NavigationLinks:

NavigationLink(destination: EmptyView()) {
    EmptyView()
}
aheze
  • 24,434
  • 8
  • 68
  • 125