DismissKeyboard を呼び出すときに、すべての UITextField を rejectFirstResponder に追加しました。
現在選択されている UITextField の ID を取得して、resignFirstResponder にする方法はありますか?
#import "NewBabyViewController.h"
@interface NewBabyViewController ()
@property (weak, nonatomic) IBOutlet UITextField *BabyName;
@property (weak, nonatomic) IBOutlet UITextField *BabyNickname;
@end
@implementation NewBabyViewController
- (void)viewDidLoad
{
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(dismissKeyboard)
];
[self.view addGestureRecognizer:tap];
}
-(void)dismissKeyboard{
[self.view endEditing:YES];
//[self.BabyName resignFirstResponder];
//[self.BabyNickname resignFirstResponder];
}
-(IBAction)textFieldDone:(id)sender
{
[sender resignFirstResponder];
}
@end