ios 处理WKContentView的crash
生活随笔
收集整理的這篇文章主要介紹了
ios 处理WKContentView的crash
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
http://www.jianshu.com/p/7ef5814a871b
?處理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]; }
解決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]; }
轉載于:https://www.cnblogs.com/xsyl/p/6419509.html
總結
以上是生活随笔為你收集整理的ios 处理WKContentView的crash的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 关于前端缓存的一个封装思路
- 下一篇: 设计包含min函数的栈