How to move to the next TextField SwiftUI?

SwiftUI: Fixing keyboard issues, while creating forms [iOS 14- XCode 12]

Prafulla Singh
3 min readApr 30, 2021

In this tutorial, we are going to implement custom TextField. This TextField will have capabilities to pass Keyboard focus. Along with this, we will also enable interactive keyboard dismissal to create better UX for views with multiple TextField like forms.

Let’s divide the problem into smaller subtasks and solve them one by one.

  1. Wrap UIKit’s UITextField using UIViewRepresentable
  2. Enable this new TextField to pass keyboard using cross binding
  3. Add Toolbar for numeric keyboard as they do not have next button inbuild
  4. Use Introspect to enable interactive keyboard dismissal.

UIKit’s UITextField using UIViewRepresentable:

Create simple UIViewRepresentable with all required parameters like placeholder, text binding, keyboard type.

Set up coordination with TextField delegate. We are going to use these delegates to toggle TextField Focus.

--

--