1

I'm trying to implement a search bar in SwiftUI using the following tutorial: https://medium.com/better-programming/implement-searchbar-in-swiftui-556a204e1970

However, I don't want to dynamically update the view. I want to update the view only after the user clicks on the blue 'Search' button at the bottom of the keyboard. However, I have no idea how to communicate between Searchbar.swift and my other screen, let's call it Feed.swift.

This StackOverflow post details how to fire events on button press from the keyboard: How do I get the return key to perform the same action as a button press in Swift?

However, it seems to be targeted to those using only UIKit in their development.

How can I leverage these to fire an event from UIKit to SwiftUI to update my feed?

ryansle
  • 251
  • 2
  • 14
  • Check out the TextField's `onCommit` parameter https://developer.apple.com/documentation/swiftui/textfield – Jack Apr 28 '21 at 15:10

0 Answers0