您好,欢迎来到二三四教育网。
搜索
您的当前位置:首页最新版本IQKeyboardManager第三方库中"

最新版本IQKeyboardManager第三方库中"

来源:二三四教育网

这是老版本的第三方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]];

}

}

Copyright © 2019- how234.cn 版权所有 赣ICP备2023008801号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务