views:

118

answers:

2

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?

A: 

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

Seva Alekseyev
A: 

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];

Chris