Bas*_*rop 7 keyboard objective-c ios
我有一个UITextView从键盘接收输入.选中"自动启用返回键"复选框,因此当该项UITextView为空时,将禁用"返回"键.
键盘上方有一个表情符号栏,可以添加表情符号UITextView,但这就是问题所在; 当它UITextView是空的时我添加一个表情符号UITextView:
[inputTextView insertText:@"\ue40d"];
Run Code Online (Sandbox Code Playgroud)
然后仍然禁用ReturnKey,尽管UITextView的text属性不为空.
插入表情符号后我试过这个:
[inputTextView setEnablesReturnKeyAutomatically:NO];
Run Code Online (Sandbox Code Playgroud)
没有结果.看起来只能通过键盘输入字符来触发启用/禁用键盘的返回键.
任何想法如何手动启用/禁用Return键?
这有点麻烦,但您可以尝试通过粘贴板插入文本:
UIPasteboard* generalPasteboard = [UIPasteboard generalPasteboard];
// Save a copy of the system pasteboard's 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];
Run Code Online (Sandbox Code Playgroud)