Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
对于 iphone 应用程序进行长文本输入,我们使用 UITextView。但键盘如何返回。[textView resignFirstResponder] 不适用于 UITextView。
在你的界面中声明 UITextViewDelegate 协议。然后实现委托方法
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { if([text isEqualToString:@"\n"]) { [textView resignFirstResponder]; return NO; } return YES; }