On my iOS app's chat screen, words get auto-corrected after the user enters a space. But the last word does not get auto-corrected when the user taps Send. How can I get the suggested word to replace the misspelled word when the user taps Send?
The last solution forces you to hide your keyboard. I found a solution that autocorrects the last word without resigning the keyboard by adding a space at the end before submitting:
// This will force the autocompletion to take effect
text = [NSString stringWithFormat:@"%@ ", text];
// Remove the last character afterwards
text = [text substringToIndex:[text length]-1];
If you call resignFirstResponder
on your text field as the first action after pressing send, it will accept the correction before sending.
- (IBAction)sendButtonPressed:(id)sender
{
[textField resignFirstResponder];
// Send the textfield's text
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With