SwiftUI Form w/ TextField, DatePicker, Toggle, Stepper, Link and Sections w/ Header
Вставка
- Опубліковано 4 тра 2021
- Head to squarespace.com/seanallen to save 10% off your first purchase of a website or domain using code SEANALLEN.
In today's video I show you how to create a Form in SwiftUI. We'll build a SwiftUI View that resembles a typical account screen that you would find in an app. I populate the Form with common elements you may use like TextFields, DatePicker, Toggle, Stepper, and a Link. I also show you how to break the form into sections with section headers and way to handle some keyboard issues you may have with your Form.
This tutorial was created in Xcode 12.5 and Swift 5.4.
SF Symbols Video:
• What's New in SFSymbol...
If you like my teaching or presentation style, I've started creating my own courses:
seanallen.teachable.com/
Twitter:
/ seanallen_dev
Link to my book - How I Became an iOS Developer:
gumroad.com/l/sean-allen-origin
Hired.com:
hired.com/x/1n01g
Check out my podcast, iOS Dev Discussions:
itunes.apple.com/us/podcast/i...
Book and learning recommendations that help out the channel if you decide to purchase (Affiliate Links):
Ray Wenderlich Books:
store.raywenderlich.com/a/208...
Ray Wenderlich Videos:
store.raywenderlich.com/a/208...
Paul Hudson's Hacking With Swift:
gumroad.com/a/762098803
Learn Advanced Swift Here:
gumroad.com/a/656585843
Links to my iOS Dev Setup & iOS Dev Book Recommendations
www.amazon.com/shop/seanallen
#swift #softwaredeveloper #iosdeveloper - Наука та технологія
If you enjoy my teaching/presentation style, I started creating my own iOS development courses at seanallen.teachable.com. You can watch the first ~10% as a free preview to get a feel for them.
I love it . i love your coding style because of amazing skill you have .
SwiftUI becomes even easier after Sean's explanation...
Thank you Sean!
Thanks for the kind words, Abhi.
Thank you Sean for all the tutorials, I don't have a Macbook yet but, I will use mac in cloud, I can't wait to play with swiftUI🚀🚀
Very clear and helpful. Thanks, Sean.
This is a great demo of where SwiftUI shines vs UIKit. Thanks Sean.
Agreed. Really excited to see the improvements at WWDC this year. Hopefully we get another big step.
Super helpful and informative!! Thank you!!
Thanks for the demo, can add this to my project now. 👍🏻
Glad to help, Karho.
Man Very easy to learn.. I am doing the screen while watching your videos. Thanks alot..
Happy to help, Manoz!
this is really great, keep up the great work Sean Allen
Thanks, will do!
Thank You i learned a lots of new things
The master of IOS is you, Sean. Can’t believe I’m doing my first app thanks to you. Cheers from Argentina, my friend!
Best of luck with the app, Martin!
Great tutorial again Sean, thanks!
Glad you liked it!
You are the best, bro ;)
Good lesson Sean... thank you
Happy to help, Andrej.
very nice video, thanks,is helpful for me
Glad you liked it, Naicai!
Hey Sean, would love to see a SpriteKit series on youtube or a new course about it. Many of us would like to dive into iOS game development and all the tutorials out there are 3-5 years old. Also great video!
SpriteKit videos are pretty high on my to-do list. You may see those soon...
Gréât vidéo , Thanks you Allen
Happy to help!
Sweet! Thanks
Happy to help, Tom.
Very good content. Thank you for your efforts.
My pleasure
@@seanallen Can you please make a video how to segue on button click in SwiftUI. I find it quite difficult.
Nice video. A tip for automatically creating closures: you can just hit enter and Xcode should automatically create the closure. E.g. when creating a Button(LocalizedStringKey, () -> Void), when you click enter on () -> Void it will create the closure.
Thanks for the tip, Fady! That always gets me.
Hey Sean, It would be great if u made a part2 video to show how to validate TextField inside a form so it shows if the content is valid like if it is a valid email or valid number of characters
Excellent.
Glad you liked it!
Very useful.
Glad it was helpful, Frank.
Nice video. Thing starts becoming tricky when we must deal with entering numbers in TextField. Could be great to have a lesson on this.
Oh yeah, there are many variations in which you can take this form that presents all new topics to discuss. I wanted to keep this basic as a starting point for forms.
super video
Fire tuts
Thanks Sam.
You7good Sean. Keep doing good 👍 work 👏.
Will do!
Sean great video! So.. if less is more... how might you refactor this so the keyboard dismiss button only appears in the toolbar when the keyboard is actually displayed.
Hi Sean, thanks for the video! Question: Do all of your videos follow the MVVM outline? I'm new to both SwiftUI and MVVM, so I'm trying to make sure I'm learning both simultaneously.
hey man, would really like to see you post a file with the source code on it. much appreciated. keep on with the great content.
why I don't see the file info.plist on my project . You are a great teacher. Thank you!
Hi Sean Allen! Could you tell me how you capture yourself speaking on your screen while recording the screen?
@seanallen amazing content like always!
How can you go to next text field when tapping the return button?
I had to create my own UIViewRepresentable UIKit text field for that.
Also, the fact that we cannot decide which event should not be canceled by adding a tap gesture over it is really lacking to SwiftUI (setting a tap priority would be great). Hopefully next WWDC we will see that 🙏🏻😅
Yeah, it's a complete oversight on Apple's part. Hopefully we'll see it fixed in SwiftUI 3.0 soon, but of course, that will require iOS 15.
Hi Sean! first of all, Thank you for your Videos. I followed your steps on Xcode 13 and the very new macOS Big Sur 11.6 and neither on the preview of the Xcode nor in the simulator the keyboard pop up to use it. Any suggestions Allen, anyone?
I want to design list of cards detail and after selecting any particular card want to display a textfeild inside that row. Can you please share any video for that
How to make an edit text view? So for example you filled in this form but you want to edit it. It would be nice if the text you already wrote is there to be edited.
Sean, can you have a blank value in the date field? You have it as a birthday but it defaults to "todays" date and if you don't know the person's bday, it will have it wrong.
Great video! Just wondered if you were doing this with a firebase database, how would you save the details entered into the form? Thank you!
I can't help much here as I've never used Firebase. All the apps I've worked on have had a custom built backend for them.
How do you change the white background in the form. I was able to change the foreground but not the background
Can rthe dismiss keyboard icon be added to the keyboard modal view itself? You only need to show this icon/button when the keyboard is shown.
Can you place the “if” from the toggle in another file so it’s showed in another view?
what version of xcode and swift do you used for this tutorial
how do you get the information put in this form sent to like a list in another view? I'm trying to create an inventory form. For example: I have 10 brown boots, 6 red heels, 2 sundresses, 3 black purses. How would I make the stepper count it and then send it to another screen that would show that information in a list style?
1:44 is it possible to create that 2 different textfield that in 1 group with UIKit or its just possible with SwiftUI?
How can we archive the exact same result using swift?
Code for the keyboard
#if canImport(UIKit)
extension View {
func hideKeyboard() {
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
}
}
#endif
Thanks for sharing!
@9:30 update: the bug is still there. I'm fully updated Sep-2021 and the bug is still alive and well :D
how can I send the input to an email by clicking on a button?
is there a way to save the data even after the application is closed
Really awesome ! however i have one question i noticed that when the Datepicker is activated and i select a date on Simulator the datepicker does not dismiss unless i tap outside. Is it a default IOS Behaviour ? thanks
That is the default behavior for the new datepicker in iOS 14.
What's that xcode theme?
From zero programming knowledge to learning swift how long would it take? Assuming you have like an hour a day to learn?
It's a tricky question, a bit like asking "how long until I can play the piano?".
You could learn the C major scale in a day, but may not be able to play "Twinkle, Twinkle, Little Star" for a month. Or a year.
You could learn to write a small, very simple app within a week. It will probably have bugs, and won't do much, but it will be a start.
You then repeat the process, building on your skills each time, producing more advanced apps.
In the meantime, the technology will change. Sometimes radically. e.g. SwiftUI. You will have to adapt.
You will make any mistakes, big and small.
Your job is to learn from those mistakes, and learn how to learn effectively.
But there will never be a time where you don't make mistakes. Instead, you will learn how to overcome them and move on.
Like playing the piano.
Good luck. You can do it, if you apply yourself consistently.
Like playing the piano.
This is exactly where I am. I was a developer about 15 years ago. My plan is to spend 200 hours learning before I can evaluate how long this will take and my ability to pick it up. I am 100 hours in and not feeling confident yet. LOL
Button - hideKeyboard doesn't work on mine for some reason :/
Hey Sean, how can i talk to you 1 to 1?
Looks like "RED" is your fav colour Sean.
It's the brand color... I don't really have a favorite color. But there are certain color combos I like, such as black/red.
SwiftUi is such a p.o.s. technology. Sections especially is a nightmare to work with
Why don't you guys ever explain what you are doing? None of this makes any sense and is impossible to follow.