I'm trying to change the "Return" key on a UITextView (not UITextField) to a "Done" key. I have the following code that doesn't update the button and leaves the button unchanged. The button starts as a "return" key and if they hit "return" once I want it to change to a "done" key.
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
// this is only run when they hit return once
textView.returnKeyType = UIReturnKeyDone;
[textView reloadInputViews];
}
More than a clean solution, this is a bit of a hack. You could try to hide and show the keyboard (i.e. resignFirstResponder, change the return key style and becomeFirstResponder).
But it will produce a weird animation. To avoid this glitch, you should be able to prevent the screen from being refreshed.
BTW, at the end of this method, do you return YES or NO?
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