iOSUITextField 响应键盘的return 事件

mac2024-11-29  25

 

 

UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 100, 30)] textField.returnKeyType = UIReturnKeySearch; //设置按键类型 textField.enablesReturnKeyAutomatically = YES; //这里设置为无文字就灰色不可点

 

在代理方法中响应

- (BOOL)textFieldShouldReturn:(UITextField *)textField { [self searchAction]; [textField resignFirstResponder]; return YES; }

 

最新回复(0)