这是老版本的第三方IQKeyboardManager 写法
-(void)doneAction:(IQBarButtonItem*)barButton
{
//If user wants to play input Click sound. Then Play Input Click Sound.
if (_shouldPlayInputClicks)
{
[[UIDevice currentDevice] playInputClick];
}
UIView *textFieldRetain = _textFieldView;
BOOL isResignedFirstResponder = [self resignFirstResponder];
if (isResignedFirstResponder == YES &&
textFieldRetain.doneInvocation)
{
[textFieldRetain.doneInvocation invoke];
}
//发送通知
if (textFieldRetain.tag==50001) {
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:@"doneAction" object:nil userInfo:nil]];
}
}
这是最新的版本写法
-(void)doneAction:(IQBarButtonItem*)barButton
{
//If user wants to play input Click sound. Then Play Input Click Sound.
if (_shouldPlayInputClicks)
{
[[UIDevice currentDevice] playInputClick];
}
UIView *currentTextFieldView = _textFieldView;
BOOL isResignedFirstResponder = [self resignFirstResponder];
if (isResignedFirstResponder == YES && barButton.invocation)
{
if (barButton.invocation.methodSignature.numberOfArguments > 2)
{
[barButton.invocation setArgument:¤tTextFieldView atIndex:2];
}
[barButton.invocation invoke];
}
UIView *textFieldRetain = _textFieldView;
BOOL isResignedFirstResponder = [self resignFirstResponder];
if (isResignedFirstResponder == YES && textFieldRetain.doneInvocation) { [textFieldRetain.doneInvocation invoke];
}
}
}
大家仔细看会发现新的版本把监听方法去掉了,所以造成监听失效
那解决办法是
-(void)doneAction:(IQBarButtonItem*)barButton
{
//If user wants to play input Click sound. Then Play Input Click Sound.
if (_shouldPlayInputClicks)
{
[[UIDevice currentDevice] playInputClick];
}
UIView *currentTextFieldView = _textFieldView;
BOOL isResignedFirstResponder = [self resignFirstResponder];
if (isResignedFirstResponder == YES && barButton.invocation)
{
if (barButton.invocation.methodSignature.numberOfArguments > 2)
{
[barButton.invocation setArgument:¤tTextFieldView atIndex:2];
}
[barButton.invocation invoke];
}
// UIView *textFieldRetain = _textFieldView;
//
// BOOL isResignedFirstResponder = [self resignFirstResponder];
//
// if (isResignedFirstResponder == YES &&
// textFieldRetain.doneInvocation)
// {
// [textFieldRetain.doneInvocation invoke];
// }
//发送通知
if (currentTextFieldView.tag==50001) {
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:@"doneAction" object:nil userInfo:nil]];
}
}