实现委托UITextFieldDelegate, UITextViewDelegate里以下方法
#pragma mark 放弃“第一响应者”
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
return YES;
}
-(BOOL)textView:(UITextView *) textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
if([text isEqualToString:@"\n"]){
[textView resignFirstResponder];
return NO;
}
return YES;
}
时间: 2024-10-02 11:38:29