문제

I have a form that looks like the following (see image). If the user hits the Login button, I want the keypad to disappear. How do I do that.

Note that TextFieldDelegate methods wouldnt get called since the user is simply hitting the UIButton (Login). Hence, anything I can put in the IBAction for this button?

alt text

도움이 되었습니까?

해결책

Normally the keyboard should be dismissed automatically when the user taps somewhere outside of the textfield, but you can also manually hide it using

[textField resignFirstResponder]

다른 팁

 set delegate for your text field <UITextFieldDelegate>
 and over ride this method

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
   [textField resignFirstResponder];
    return YES;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top