zoukankan      html  css  js  c++  java
  • ios 处理WKContentView的crash

     
     

    解决WKContentView没有isSecureTextEntry方法造成的crash

    程序中有web页面,使用WKWebView,但是有个crash一直存在:
    [WKContentView isSecureTextEntry]: unrecognized selector sent to instance 0x101bd5000
    网上搜索,并没有结果,是太简单了吗?不清楚,准备使用runtime给WKContentView添加一个方法,观察下


    在程序启动的时候调用一下progressWKContentViewCrash方法就可以

    /**
     处理WKContentView的crash
     [WKContentView isSecureTextEntry]: unrecognized selector sent to instance 0x101bd5000
     */
    + (void)progressWKContentViewCrash {
        if (([[[UIDevice currentDevice] systemVersion] doubleValue] >= 8.0)) {
            const char *className = @"WKContentView".UTF8String;
            Class WKContentViewClass = objc_getClass(className);
            SEL isSecureTextEntry = NSSelectorFromString(@"isSecureTextEntry");
            SEL secureTextEntry = NSSelectorFromString(@"secureTextEntry");
            BOOL addIsSecureTextEntry = class_addMethod(WKContentViewClass, isSecureTextEntry, (IMP)isSecureTextEntryIMP, "B@:");
            BOOL addSecureTextEntry = class_addMethod(WKContentViewClass, secureTextEntry, (IMP)secureTextEntryIMP, "B@:");
            if (!addIsSecureTextEntry || !addSecureTextEntry) {
                NSLog(@"WKContentView-Crash->修复失败");
            }
        }
    }

    /**
     实现WKContentView对象isSecureTextEntry方法
     @return NO
     */
    BOOL isSecureTextEntryIMP(id sender, SEL cmd) {
        return NO;
    }

    /**
     实现WKContentView对象secureTextEntry方法
     @return NO
     */
    BOOL secureTextEntryIMP(id sender, SEL cmd) {
        return NO;
    }
     
    app delegate:
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
     
     //处理crash
        [AppCrashProcessManager progressCrash];
    }
  • 相关阅读:
    crm-ssh-列表显示(顾客列表,用户,联系人列表)
    leetcode- Rotate Array 旋转数组
    ssh的整合
    svn详解和使用
    leetcode-Plus One 加一
    spring-jdbc-aop事务
    leetcode-Remove Duplicates from Sorted Array
    0020 DRF框架开发(07 基类视图 GenericAPIView)
    0019 DRF框架开发(06 基类视图 APIView)
    0018 DRF框架开发(05 序列化器的字段与选项)
  • 原文地址:https://www.cnblogs.com/xsyl/p/6419509.html
Copyright © 2011-2022 走看看