This one will work:
You need to use NavigationLink with an activation parameter so that you can track the start of navigation. When switching the navigation link activation parameter, force the keyboard to be removed
extension UIApplication: UIGestureRecognizerDelegate {
func dismissKeyboard() {
sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
}
}
Button {
UIApplication.shared.dismissKeyboard()
activateLink = true
} label: {
Text("Activate link")
}
.background(
NavigationLink(destination: DestinationView(), isActive: $activateLink) { EmptyView()}
)
In iOS 15, there are no such problems.
Post
Replies
Boosts
Views
Activity
You don't need to use a specific .plaint style, but you need to apply ANY (whatever you want) style to the list and then everything will be ok.
The problem is that you have NavigationLink placed in the ForEach cycle! You need to remove NavigationLink from the cycle and transfer the necessary data there, for example, through the view model.
Summary: you must have only one NavigationLink with the "IsActive" parameter.
My original answer - https://stackoverflow.com/questions/66017531/swiftui-navigationlink-bug-swiftui-encountered-an-issue-when-pushing-anavigatio/67626758#67626758