So will come again in this lesson we're going to talk about textfield.
We use text fields for any situation where a user has to enter text entry values so that is username
and password or it is the user's phone number or if it's a form on an application that user has to enter
multiple different text.
We rely on text as photos.
So let's go ahead into ex-school and in the next quote I'm going to say or start a new project my new
project is obviously a single view outgassing called Text fields.
And then once it loads I'm going to go to my storyboard my storyboard I'm actually going to go ahead
and say Give me a text field I'm going to place it some about here.
Now if you pay attention you will see that textfield they don't let should change their height and that
is because of their borders style by default that around borders sign.
So I'm going to go to the editor and I'm going to change the border a style to be no border at all.
And now it becomes like hey you I your are you I label that I can do pretty much whatever I want to
do with it.
So I'm going to change the signs.
I'm going to say it's back.
It's actually a light gray color.
All right so now I was here light gray color and I'm actually going to add a placeholder for it say
user name.
All right.
A place holder is essentially something that you see in textfield.
Unless you start modifying it.
And I'm going to send three line it to the center.
Then let's go ahead and duplicate this on the duplicated one.
I'm going to say this is actually e-mail and that's all that I I'm going to add one more.
This one is going to be our let's say H and there's a reason I'm doing these three in particular.
So let's change the keyboard for all of these.
I'm going to say for a user name the key word should be the default keyboard.
And then for e-mail the keyboard type should be an e-mail address keyboard and for H I one my keyboard
to be a numeric keyboard which is this one a number of pop.
So then let's say I am one to have a button that submits this information.
So I'm going to add a button and that button is going to be here and this but then maybe I call it actually
met some met with a bygone that's a little bit more clear for what it's going on in here.
I will finally add a label that's going to show us the status of our submission for now is not really
going to do anything it's just going to be there so we know that we did or we didn't submit so.
And that's my art.
Let's say resorte label and so it's as a result.
QUESTION Mike for now.
So great we have two text fields one submit button and one results are labeled.
Let me just get myself a little bit better space like that.
Fantastic.
Now I need to do is I need to make the outlets for all of these.
So that's going to be very easy.
We've done it many many times before.
I'm going to my assistant editor in the assistant head somewhere along the dot H I am at that age I'm
going to say let's get a little bit better spacing in here.
And this is going to be user name and takes for the next event.
This is going to be email text field.
This is obviously going to be a text field.
This is going to be resolved label.
And finally I have a soft Mitt action submits action.
Remember that for the submit change the connection to an action.
So now I have four outlets which are here in my age username textfield email textfield age text field
on the label.
And then I have this submit action.
Now let's go ahead into our coding.
You are in that am I'm going to clean everything up.
Of course I have to have my view with it.
I have my self made action which is the action that you have over there.
So let's see what we want to do.
So when I press the submit button I want to get the username I want I get there age.
I also want to get their e-mail address and I want to submit all of them into one string and show it
in the resort.
So that's what we want to do is simple.
I'm going to say and I Sistrunk name is going to be the user name or what they call they call it user
name didn't I.
Yes user name which is going to be user name textfield dot text and then enter a strange e-mail is going
to be e-mailed textfield the dot text and then I have A.S. Thring H is going to be H textfield h textfield.
They call it age text with what they call it age text filthiest text.
And then I'm going to have one string that appends all of these together.
That's going to be unnecessary.
Let's call it the phrase string.
And that's going to a and as a string string with formats bring ring format and the format is this name
or let's say What if the values name via email and something.
All I'm saying.
Years old.
So here's what's going to happen.
I'm going to say the first volume is named the second one is e-mail and the last one is age.
So what's going to do is going to say whatever name we read whatever e-mail these many years or so that's
what we wanted to see.
And we're going to put it in the Rose label dot text.
It's going to be a string.
Apparently they have misspelled that so let's call it this ring and that's about it.
So let's run this application Now if all goes well which I'm hoping you will.
We should be able to answer all of these values and also see them in our Laymon.
So user name.
I'm going to put my name on here and then and here is Zamperla dot com an age I'm going to say 100 at
age years old submit.
I mean really I mean examples come on 100 years or exactly what we expect in a few little you know housekeeping
matters one of them is that we wanted to get rid of the keyboard.
If you don't see the keyboard at all it's because your keyboard is not being shown and you can go to
a keyboard and say toggle sauf keyboard.
So that's command case.
So if you had come on your keyboard will appear.
But then when we had submit it doesn't disappear.
So here's what we're going to do in this segment and I'm going to get myself a little better spacing
in here in the submit.
I'm going to say username text didn't resign the first responder.
And then I'm going to say e-mail textfield resign the first responder.
And of course H takes will resign first responders so get rid of all of the keyboards that use to get
rid of the keyboards resigning the first responders.
So that's one thing I need to fix.
So now whatever I enter in here and then year and 200 submit keyboard disappears you see when I go here
the cable shows up and I had made it disappear.
And also I don't know if you know is but depending on the text will we go to our keyboard is changing.
This is the default keyboard.
This is the keyboard for e-mail.
It has the odd sign on this obviously the numeric keyboard that allows us to enter numeric values.
Another thing you probably want to do is you want to clean all of these.
So once you submit you want to make all of them empty that would be very simple.
That would be user name takes real dot text becomes empty.
And then when I copy this.
And the next time it's going to be email textfield and the last thing is going to be age textfield.
So let me get a little with a spacing in here so we can see everything in our function so far.
And let's read on it now.
It i have my name I have my email and I have my own age and I have to submit.
The keyboard disappears.
They all go on here for some reason.
And here's a big mistake that I made.
Everything has become empty.
Why is that.
Because I forgot to first do everything I want to do and then empty my text fields.
I emptied my text with a little bit in a rush thought let's cut this off point at the very end.
So once you have known everything that you want to do then empty the text field.
So this time everything should work.
In here I have once again my name my e-mail and a 100 A submit they appear here and everything clears
up.
Now a few really quick notes that if you need that you can obviously change the keyboard size in almost
every word you can do it in the text keyboard.
They come up more frequently than the others.
So for instance like with say e-mail text failed thought the keyboard to type.
And it says you have to give me a new keyboard type so I'm going to say you my keyboard to type and
then I forget it is the one that I want.
Actually it's an e-mail so I don't want that.
I want an e-mail one so that's an easy thing you can change it either in the interface builder or here
in the code.
The other thing that I should mention to you guys is that there are values that we are receiving here
are all Ennis's strings so the value you getting for the age is not a numeric value it's an actual Ah
what you call a text value.
So for instance if I go in here and I write 100 This isn't 100.
This is 1 0 0 that the reads are 1 0 0 4 in US history not a numeric number which is after 99 and before
1 0.
One hundred and one.
So if you want you can actually try to get the integer values.
So for instance I could go in here and say it's age and it is going to be age text textfield dot text
interline you.
This isn't specific to our text.
This is specific to strings so we can say extract the integer value out of here.
So it's going to go in there and it's going to look for the value.
And if you have something like this is going out and only find the first three letters it's going to
say 100 is the number I can make out of here.
And that survey that you could use it for this in the future in about in the next section essentially
when we learn about the delegation we will then raise about forcing these takes readers to accept certain
type of characters.
Right now the keyboard for age is numeric but you could actually enter other values you know on an actual
device you can change the keyword and you could actually enter other values just like whoa.
Now I'm actually entering you know string values or characters.
Once you learn about you I textfield delegation will learn about ways to force this to only accept numbers.
So when you had I don't know 25 a a would automatically delete and as many times as you try it doesn't
let you fill in any non numeric values but because say this down that's right.
And with that I think we're a good fit.
The text feels for entering text into the values.
I will see you in the next lesson.