[WebActionDisablingCALayerDelegate willBeRemoved]: unrecognized selector sent to instance xxxxx

WebActionDisablingCALayerDelegate类找不到相应的方法实现,提示 [WebActionDisablingCALayerDelegate willBeRemoved]: unrecognized selector sent to instance xxxxx

用weibiew加载html的时候,如果CSS文件里边用到了这个属性:

-webkit-overflow-scrolling: touch(这个属性是实现弹性的滑动,类似scrollview的bounces效果);加载的时候,会提示这个错误,如果你不打全局断点,程序是不会崩溃的,如果有,就会崩溃.

解决办法:

1----html里面去掉这个属性,如果不去掉也没事,真机运行不会崩溃

2----用WKWebView来代替UIWebView

3----报错是说类找不到相应的方法实现,那么可以自己实现一下,给UIWebView增加一个category,用runtime来给这个类添加这个方法实现

+ (void)load {

Class class = NSClassFromString(@"WebActionDisablingCALayerDelegate");

class_addMethod(class, @selector(setBeingRemoved), setBeingRemoved, "v@:");

class_addMethod(class, @selector(willBeRemoved), willBeRemoved, "v@:");

class_addMethod(class, @selector(removeFromSuperview), willBeRemoved, "v@:");

}

id setBeingRemoved(id self, SEL selector, ...) {

return nil;

}

id willBeRemoved(id self, SEL selector, ...) {

return nil;

}

posted @ 2022-01-18 16:29  OIMMZC  阅读(126)  评论(0)    收藏  举报