1. Add delegate,2. Set a delegate, 3. Implement the following 3 methods:
When you start editing the input box, the soft keyboard appears, performing this event
-(void) textfielddidbeginediting: (Uitextfield *) TextField
{
CGRect frame = textfield.frame;
int offset = FRAME.ORIGIN.Y +-(self.view.frame.size.height-216.0);//Keyboard Height 216
Nstimeinterval animationduration = 0.30f;
[UIView beginanimations:@ "Resizeforkeyboard" context:nil];
[UIView setanimationduration:animationduration];
Move the y-coordinate of the view up to offset units so that the space below is used for the display of the soft keyboard
if (Offset > 0)
Self.view.frame = CGRectMake (0.0f,-offset, Self.view.frame.size.width, self.view.frame.size.height);
[UIView commitanimations];
}
Keyboard disappears when the user presses return or presses the ENTER key
-(BOOL) Textfieldshouldreturn: (Uitextfield *) TextField
{
[TextField Resignfirstresponder];
return YES;
}
Restore the view to its original state when the input box is finished editing
-(void) textfielddidendediting: (Uitextfield *) TextField
{
Self.view.frame =cgrectmake (0, Self.view.frame.size.width, self.view.frame.size.height);
}
IOS Keyboard Masking textfiled issues