-(IBAction)settings:(id)sender
{
[mileagerate resignFirstResponder];
[mainView bringSubviewToFront:mileageView];
mainView.hidden=TRUE;
[UIView beginAnimations:@"Settings" context:nil];
[UIView setAnimationDuration:1.0];
[mainView setFrame:CGRectMake(0, 0, 320, 460)];
[UIView commitAnimations];
mileagerate.text = [[NSUserDefaults standardUserDefaults] valueForKey:@"savedstring"];
mileageView.hidden=FALSE;
}
I used resign first responder in various places in my app. But when i click on this button alone, the keyboard does not disappear. If i click on the return key in keyboard, the entered value disappears.
Use below line of code in your method if you don't know which textfield
to resign:
self.view.endEditing(true)//resign current keyboard
[self.view endEditing:YES]; //resign current keyboard
EDIT : Note : It will resign keybord
from your current view
.
check your .h file if you have put the TextFieldDelegate over there. . Some time if we not declare its delegates function doesn't work properly.
I think when you are setting the text, textField mileagerate is becoming first responder again, so use this statement at last of the method
[mileagerate resignFirstResponder];
You have to first use a
[UIView setAnimationDidStopSelector:@selector(yourMethod)];
Then in the "YourMethod
" resign your keyboard.
- (void)yourMethod
{
[mileagerate resignFirstResponder];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With