iOS:UITextView中return key点击事件的监听方法

可以这样解决,在- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text中监听replacementText,如果为回车则将键盘收起

 

 

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{

    if ([text isEqualToString:@"\n"]) {
        
        [textView resignFirstResponder];
        return NO;
    }

    return YES;
}

你可能感兴趣的:(UITextView,replacementtext)