In the view of the Uitextfield often need to enter the text after the hidden soft keyboard, to achieve a point to let the controller implementation of the view Uitextfielddelegate proxy, and then write the corresponding code.
- #import <UIKit/UIKit.h>
- @interface testveiwcontroller:uiviewcontroller<uitextfielddelegate> {
- Iboutlet Uitextfield *txt;
- }
- @property (Nonatomic,retain) Uitextfield *txt;
- @end
|
Then remember to specify the proxy for the text box
- -(void) Viewdidload {
- [Super Viewdidload];
- Txt.delegate = self;
- }
|
To hide the soft keyboard when you click Enter:
- -(BOOL) Textfieldshouldreturn: (Uitextfield *) TextField
- {
- [TextField Resignfirstresponder];
- return YES;
- }
|
Click Cancel or the deserted number to hide it. Note that there is no way to hide the return yes, I used a bit of a workaround.
- -(BOOL) Textfieldshouldclear: (Uitextfield *) TextField
- {
- [TextField Resignfirstresponder];
- Textfield.text = @ "";
- return NO;
- }
|
Click Other areas of the view to hide the soft keyboard.
- -(void) Touchesbegan: (Nsset *) touches withevent: (Uievent *) event
- {
- [txt resignfirstresponder];
- }
|
I have used my custom variables directly here.
The steps to set up the agent are important, don't forget, or you won't respond.