Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I force the keyboard to stay displayed?
    text
    copied!<p>I have an IBAction that is called when someone is done entering text in a field. I then validate the input. If I have determined there is an error, I display a message and want the user to enter into that same field again. Rather than make them select the text field to bring the keyboard up (which works fine) I want to just leave the keyboard displayed.</p> <p>I am doing <code>[SymbolEntered becomeFirstResponder];</code> as the last statement in my IBAction, but the keyboard still goes away. Am I putting that in the wrong place? Any help would be appreciated. Thanks.</p> <pre><code>- (IBAction)textFieldDoneEditing:(id)sender { DebugMsg.text = nil; DebugMsg2.text = nil; DebugMsg3.text = nil; NSLog (@"done editing"); NSLog (@"%@", SymbolEntered.text); if ([SymbolEntered.text isEqualToString:nil]) { Result.textColor = [UIColor redColor]; Result.text = @"You must enter a symbol!"; [SymbolEntered becomeFirstResponder]; } else { if ([SymbolEntered.text isEqualToString: [NSString stringWithCString:elements_table2[el_tbl_idx-1].element_symbol]]) { correct_count++; Result.textColor = [UIColor greenColor]; Result.text = @"Correct!"; Score.hidden = FALSE; Score.text = [NSString stringWithFormat:@"Score: %d out of %d - %d Percent", correct_count, el_count+1, (correct_count*100)/(el_count+1)]; GetNextElementButton.hidden = FALSE; SymbolEntered.enabled = FALSE; el_count++; attempts = max_tries + 1; } else { Score.hidden = TRUE; Result.textColor = [UIColor redColor]; if (attempts &lt; max_tries) { if (attempts+1 == max_tries) { Result.text = @"Sorry, one more try -"; } else { Result.text = @"Sorry, try again - "; } GetNextElementButton.hidden = TRUE; attempts++; } else { Result.text = [[NSString alloc] initWithFormat: @"Sorry. The correct answer is %@", [NSString stringWithCString:elements_table2[el_tbl_idx-1].element_symbol]]; Score.hidden = FALSE; Score.text = [NSString stringWithFormat:@"Score: %d out of %d - %d Percent", correct_count, el_count+1, (correct_count*100)/(el_count+1)]; GetNextElementButton.hidden = FALSE; SymbolEntered.enabled = FALSE; el_count++; } } } [SymbolEntered becomeFirstResponder]; NSLog (@"end of textfieldoneediting"); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload