Andres Bucci
Andres Bucci

Reputation: 947

iOS keyboard won't dismiss after view dissappears

I have been looking for a similar questions but so far the answer doesn't fit my purposes. I have a UITableViewController inside A UINavigationController with custom UITableViewCells containing textfields inside. When I click on the textfields they become the firstResponders and when I click return they resign it. So far so good.

My problem is one of these cells is performs a Submit function. After this is done whenever I press the textfields the return button doesn't dismiss the keyboard anymore.

My question is, since I'm not releasing anything, why do these textfields stop listening to the resignfirstresponder message?

UPDATE: I finally got this working by setting an UITextfield ivar in the class, making it the first responder whenever the textfield begins editing in :

- (void)textFieldDidBeginEditing:(UITextField *)textField
  {
      [textField setTextColor:[UIColor blueColor]];
      focusedTextField = textField;    
  }

And calling [focusedTextField endEditing:YES]; when i press the submit button. Just added this after seeing some answer in SO, but I can't remember the link, sorry.

Hope it helps.

Upvotes: 0

Views: 181

Answers (1)

ilhnctn
ilhnctn

Reputation: 2210

If you have declared a method for return(let's say your textfiled is called textField) use this code in your method;

[textField setUserInteractionEnabled:NO];//but this may restric you if you need to use it again

But if you use standard return property of the keyboard it may be something related to Apple's restrictions

Upvotes: 1

Related Questions