こんな感じで、UIControlEventEditingDidEndOnExitの時に閉じる処理呼び出せばよい。
closeKeyboard.m
// キーボード閉じる
- (void)done:(id)sender
{
[sender resignFirstResponder];
}
- (void) createTextField
{
UITextField *textField = [[UITextField alloc] init];
[textField addTarget:self action:@selector(done:) forControlEvents:UIControlEventEditingDidEndOnExit];
[self.view addSubView: textField];
}