设置textview的delegate并实现此方法, 当有文本替换时, 判断是否为回车符, 为回车则输入无效
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
if ([text isEqualToString:@"\n"]) {
return NO;
}
return YES;
}