iOS UITextField 响应键盘的return 事件

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;
}
原文地址:https://www.cnblogs.com/jukaiit/p/9255030.html