1. 遵循代理<UITextViewDelegate>
2.设置代理self.textView.delegate = self;
3. 实现代理方法:
- (BOOL)textView:(UITextView*)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString*)text
{
if([text isEqualToString:@"\n"]) {
[textView resignFirstResponder];
returnNO;
}
return YES;
}
网友评论