How can I manually enable or disable the Return Key on the keyboard?

I have a UITextView that receives keyboard input. The "Enable automatic key return" checkbox is checked, so when the UITextView empty, the return key is disabled.

I have an Emoticons panel above the keyboard that can also add emoticons to a UITextView , but here's the problem; When the UITextView empty, and I add a smiley to the UITextView as follows:

 [inputTextView insertText:@"\ue40d"]; 

then ReturnKey is still disabled, although the text property of the UITextView is not empty.

I tried this after inserting an emoticon:

 [inputTextView setEnablesReturnKeyAutomatically:NO]; 

No results. It seems that turning on / off the keyboard return key only starts by entering characters through the keyboard.

Any idea how to manually enable / disable the return key?

+7
source share
2 answers

This is a bit of a hack, but instead, you can try pasting text through a file cabinet:

 UIPasteboard* generalPasteboard = [UIPasteboard generalPasteboard]; // Save a copy of the system pasteboard items // so we can restore them later. NSArray* items = [generalPasteboard.items copy]; // Set the contents of the system pasteboard // to the text we wish to insert. generalPasteboard.string = text; // Tell this responder to paste the contents of the // system pasteboard at the current cursor location. [textfield paste: nil]; // Restore the system pasteboard to its original items. generalPasteboard.items = items; // Free the items array we copied earlier. [items release]; 
+2
source

uncheck "Enable automatic key return"

-one
source

All Articles