开发者

UITextfield is becoming focused after UIButton pressed

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 a开发者_如何学Cgain 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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜