问题
I want to trigger a function that will depend on which method the user used to resign a textField's first responder. If it was resigned by selecting another textField, it does nothing, else triggers a function. Is this possible?
回答1:
Found out how. You just have to listen to the UIKeyboardWillHideNotification
notification:
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(methodYouWantToCall) name:UIKeyboardWillHideNotification object:nil];
}
- (void)methodYouWantToCall {
//Do anything you want here
}
来源:https://stackoverflow.com/questions/8320508/how-can-i-check-if-the-hide-button-pf-ipads-keyboard-was-pressed