How To Use Text Fields in SwiftUI (2024)

preview_player
Показать описание
Learn how to use a SwiftUI TextField to capture user input. This tutorial contains sample code and common use cases for text fields.

In this SwiftUI TextField tutorial, we’ll cover:
00:00 Intro
00:12 A basic usage example
03:10 Responding to text field events such as on submit
03:56 Handling focus states on a single text field
05:41 Handling focus states on a multiple text fields

Download sample code for all SwiftUI components here:

Article version of this tutorial:

For tutorials of other SwiftUI components, check out our playlist here:
Рекомендации по теме
Комментарии
Автор

Thank you! You have a natural teaching talent. Thank you again.

Free_Time
Автор

Amazing, great video! Useful, comprehensive and entertaining too. As usual!

PhG
Автор

Hey Chris, thanks so much for the explanation on bindings!!

danielcrompton
Автор

Nice video, but does anyone know how to create a text field like in the one in the apple notes app?

Dkstyle
Автор

Thanks Chris.
What do you do about those yellow runtime warnings. I’m getting lots of weird ones when I run in simulator or device with text field/keyboward. Similar to what shows in this video.
Any suggestions?
Thanks

istalzer
Автор

Thank you, u are grate!! One problem, when i declare a specific keyboard the debug area it shows a yellow bug. Do you know what happens there?

Textfield()..
.keyboard(.numeric)
For example

sebasy
Автор

Hi. Thanks for the video. I wounder if the user is not pressing enter is it possible to save the value any way? I can another confirm button to go to next screen and wanted to save it if the user press confirm but when the user not pressing enter the value dont save =(

WattsnabbAB
Автор

There is no option to download the Kit on the website

RahulGupta-czof
Автор

what about changing the size of the textfield

ArmaannVirendraKarnnavat
Автор

Do you have any plans for videos on animations?

mohamethseck
Автор

Hmm, try keyboard in window, my test seems to leak, loses focus, hides keyboard and opens when new field appears in next, breaking continuity

codelaby
Автор

Hi there. Any of you guys got the paid course by Chris? I'm really interested in but I'm scared of not being enough good to understand how to do things. I'm learning few things, basic classic apps like card games (the one by Chris is soo good and easy to understand), a xylophone etc... in swift but also in Flutter. There are things I saw on YouTube, tutorials, where to do the same things in swift/swiftUI the code was to me soooo complicated while in Flutter I could get the point with less pain. Really want to understand how things work in swift but is it just me or ios native is harder than Flutter?

amanterobot
Автор

Why can you input content in the canvas preview? How do I set it up?

Jake-bs
visit shbcf.ru