문제

I have a UITextfield for entering text. A button triggers a functionality. After completion of the IBAction the UITextfield is getting focused again. After the IBAction I want to keyboard to disappear. What happends now is that due to the IBAction of the button, the keyboards disappears (I'm showing a UIAlert) and after the IBAction the keyboards pop's up again together with the focus in the UITextfield. Is it possible to prevent the UITextfield to be focused after the IBAction?

도움이 되었습니까?

해결책

Before displaying the alert, call [resignFirstResponder] on the UITextField.

다른 팁

Found the problem. While carrying out the operations in the IBAction method I was locking the view with:

[self.view setUserInteractionEnabled:NO];
// do the job
[self.view setUserInteractionEnabled:YES];

This activates the UITextfield again. So I put a [self.hostName resignFirstResponder]; directly behind the setUserInteractionEnabled:YES. So after coming back from the IBAction nothing is focused.

SOLUTION:

[self.view setUserInteractionEnabled:NO];
// do the job
[self.view setUserInteractionEnabled:YES];
[self.hostName resignFirstResponder];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top