首先设置TextField 或 TextView的 delegate
/UITextView
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{if ([text isEqualToString:@"\n"]) {NSLog("点击return");return NO;}return YES;
}
/UITextField
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{NSLog("点击return");return YES;
}