2016年1月12日 星期二

iOS UIWebView throw exception in runtime

While some JS will called webkit method,resulted in iOS unrecognized method.

[WebActionDisablingCALayerDelegate willBeRemoved]: unrecognized selector sent to instance

[WebActionDisablingCALayerDelegate removeFromSuperview]: unrecognized selector sent to instance

So I provided method in runtime,

+ (void)load{
Class class = NSClassFromString(@"WebActionDisablingCALayerDelegate");
SEL willBeRemoved = @selector(willBeRemoved);
class_addMethod(class, willBeRemoved, (IMP)willBeImplementation, nil);
}

void willBeImplementation(id self, SEL _cmd) {

}

While webkit call [WebActionDisablingCALayerDelegate willBeRemoved],
it was replaced by willBeImplementation.
 

2 則留言:

  1. where to provide this method in code

    回覆刪除
    回覆
    1. ref http://stackoverflow.com/questions/25894173/uiwebview-throwing-exception-for-webactiondisablingcalayerdelegate-setbeingremo

      刪除