
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(, , , )]
textField.returnKeyType = UIReturnKeySearch; //设置按键类型
textField.enablesReturnKeyAutomatically = YES; //这里设置为无文字就灰色不可点
在代理方法中响应
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[self searchAction];
[textField resignFirstResponder];
return YES;
}