3

So I have a SwiftUI gesture that causes a state change to switch between two different views. In each of these views, the central component is a TextField (in this case a CocoaTextField, which was imported with SwiftUIX (a GitHub module). Each text field is a first responder, which means it goes into focus when the view presents itself. The only problem is when I switch between the two views, the keyboard dismisses itself only to re-present itself immediately after. This can be seen in the video below:

https://youtu.be/zTBHHuse5jA

Not sure how to fix this glitch, any help would be much appreciated! (I've tried to remove animation but that's not the way to go)

Each CocoaTextField looks like this:

CocoaTextField("", text: $text, onCommit: {
    UIApplication.shared.endEditing(true)
})
.isInitialFirstResponder(true)
.returnKeyType(.done)
.enablesReturnKeyAutomatically(true)
.multilineTextAlignment(.center)
nickcoding2
  • 142
  • 1
  • 8
  • 34

0 Answers0