Member-only story
Implementing TextFieldDelegate With Native SwiftUI
Understand TextFieldDelegate methods with native SwiftUI
Here we are, less than a week away from the production release of iOS 15 and I am still hearing SwiftUI isn’t ready for production. It is sadly becoming an urban myth.
Is it true or is it that the establishment isn’t trying hard enough? To be honest, there is some truth in it. TextView
and ScrollView
are both good examples of UI elements in UIKit that in the premier case don’t exist in SwiftUI or the latter that has only been partially implemented. But it is very much a moving target and with a little bit effort, you can get some remarkably good results.
And well given the layout capabilities of SwiftUI are light years ahead of UIKit, I think it may be worth it.
Let’s look at another example, the TextField
. This has been implemented in SwiftUI, but like ScrollView
doesn’t come across as a full implementation on the surface of it. Join me on a journey to look into this with a little more vigor. I want to try and implement the TextField
with all the trimmings without resorting to UIViewRepresentable
. I want a native solution.
The Brief
The TextField
in UIKit comes with a delegate to help you use it. Within the delegate protocol, I find…