点击“按键”(键盘上)时,iOS自动填充导致崩溃

cgvd09ve  于 2023-02-14  发布在  iOS
关注(0)|答案(1)|浏览(306)

***由于未捕获异常“NSInvalidArgumentException”,正在终止应用程序,原因:'应用程序尝试以模式显示视图控制器〈_SFAppAutoFillPasswordViewController:0x106e22ee0〉已通过〈UI键盘隐藏视图控制器自动填充:0x106e25a10〉中的内容。“

IOS16(不确定其他操作系统版本是否可以重现)点击文本字段,然后键盘显示(上面有一个按键),点击按键,它随机崩溃。

cotxawn7

cotxawn71#

//IQKeyBoardManager Issues暴力事件已解决,三方数据库和系统出现问题

import“用户界面视图控制器+当前KBHook. h”

@实现UIView控制器(当前KBIook)

  • (空隙)荷载{
[UIViewController ff_swizzleInstanceMethodWithSrcClass:[UIViewController class] srcSel:@selector(presentViewController:animated:completion:) swizzledSel:@selector(cr_presentViewController:animated:completion:)];

}

  • (void)cr_presentViewController:(UIViewController *)视图控制器到当前动画:(BOOL)标志完成:(void(^)(void))完成{
if (self.presentedViewController) {
    NSLog(@"[present devil]self=%@,toPresent=%@",self.description, viewControllerToPresent.description);
}else{
    [self cr_presentViewController:viewControllerToPresent animated:flag completion:completion];
}

}
//交换两个对象方法的实现

  • (无效)ff_swizzleInstanceMethodWithSrcClass:(类)源类源选择:(选择)源选择混合选择:(选择)混合选择{
Method srcMethod = class_getInstanceMethod(srcClass, srcSel);
Method swizzledMethod = class_getInstanceMethod(srcClass, swizzledSel);
if (!srcClass || !srcMethod || !swizzledMethod) return;

//Add a layer of protection measures. If the method is added successfully, it means that the method does not exist in this class, but exists in the parent class, and the method of the parent class cannot be exchanged, otherwise the method will crash when the parent class object calls the method; Adding failure indicates that the method exists in this class
BOOL addMethod = class_addMethod(srcClass, srcSel, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));
if (addMethod){
    //After the IMP is successfully implemented by adding methods, the original implementation will be replaced with the swizzledMethod method to achieve method exchange without affecting the implementation of the parent method
    class_replaceMethod(srcClass, swizzledSel, method_getImplementation(srcMethod), method_getTypeEncoding(srcMethod));
}else{
    //Adding failed, calling the implementation of the two interactive methods
    method_exchangeImplementations(srcMethod, swizzledMethod);
}

}
@结束

相关问题