1

I am implementing a message composer as like iMessages.

enablesReturnKeyAutomatically of UITextView is not working.

I have set it as textView.enablesReturnKeyAutomatically = YES;

but when I tap on numeric keypad and start typing something and sent using my send button. the textView got empty but the send button (return button of UITextView) is still enabled.

AMohan
  • 534
  • 1
  • 6
  • 15

1 Answers1

0

enablesReturnKeyAutomatically seems to only affect the uikeyboard, which in this case is a numeric keypad. The default numeric keypad does not have a return key, so there is nothing to enable/disable.

It sounds like you have a separate send button in the view. A workaround is inside - textView:shouldChangeTextInRange:replacementText: calculate what the new string will be with the replacementText and test if this new String is equal to @"". If so, then sendButton.enabled = NO, else sendButton.enabled = YES.

Remember to set the UITextViewDelegate and to trim the new string of white space.

Josh Gafni
  • 2,831
  • 2
  • 19
  • 32
  • The issue is not with my sendButton. The issue is with keypad's send button. – AMohan Oct 30 '14 at 11:16
  • By default, the numeric keypad doesn't have a send button. Did you do something like this: http://stackoverflow.com/questions/584538/how-to-show-button-done-on-number-pad-on-iphone ? Could you post your code? – Josh Gafni Oct 31 '14 at 16:34
  • @Joshuna Gafni My key pad is normal one only. but once the user switches to keypad then also the submit button is visible. – AMohan Nov 03 '14 at 05:40