fdfd

And the Rest...

general control attributes inherited from UIControl,but

these generally don't apply to text fields,with the exception of

the Enabled Checkbox,,won't affect the field's appearance.

check Opaque,


Set the Attributes for the Second Text field

single -click the second text field in the View window, and return to the inspector.

in the Placeholder field,type Type in a number.

in the section called Text Input Traits

keyboard Type pop-up menu. ince we want the user to enter numrs only.

go ahead and select Number Pad

we don't have to set the Return Key value for the numbeic

keypad

Connection Outlets

Control-drap from File's Owner to each of the text field.

and connect them to their corresponding outlets.

Save the nib file once you;ve connected both text fields to their corresponding outlets and the go back

to Xcode

Closing the Keyboard

how do you get the keyboard to go away?

Go ahead and try.

Closing the keyboard when done is Tapped

the keyboard is software-based, we need to take a few extra steps to make sure the keyboard

goes away when the user is finsihed with it .

when the user taps the Done button on the text keyboard.

a Did End On Exit event will be generated, and at that time , we need to tell the text field to tive up control so that the key board

will go away.

add an action method to our controller class.

Control_FunViewController.h

switch over to .m, we'll implement this method.


add the following method to .m

the first responder is the control with which the user is

currently interacting. In our new method ,we tell our control to resign

as a first responder, giving up that role to the previous control the user worked with.

When a text field yields first responder status , the

keyboard associated with it goes away.

Double-click .xid to hop back ouer to IB and trigger this action from both of our tet field

single click the Name text field , press 2 to bring the connecton in

inspector  we want Did End On Exit since that is the event that will file when the uer taps the Done button on th ekeyboad

原文地址:https://www.cnblogs.com/yushunwu/p/2686582.html