Search code examples
iosuiwebviewpspdfkit

PSPDFKit and UIWebView doesn't work together


I use PSPDFKit into a static framework linked to a main project which uses another static framework with a UIWebView.

After the loading of the main project, when I launch the UIWebView and call the request, I have this error:

void SendDelegateMessage(NSInvocation *): delegate (webView:decidePolicyForNavigationAction:request:frame:decisionListener:) failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode

and nothing appends in the webview.

If I doesn't load PSPDFKit into my first framework, the issue doesn't appear and all is ok.

I also found that if I link all the frameworks needed by PSPDFKit but not the PSPDFKit, I have the same bug. I must remove the MessageUI framework to have the right behaviour. But when I include PSPDFKit even without MessageUI, the bug occurs.

Someone have an idea to solve it or find a workaround?

The bug occurs on iOS 7 versions, only on devices not on simulator. And all works fine in iOS 6.

I found this post UIWebView: decidePolicyForNavigationAction? but the resolution is not very clear!

Thanks


Solution

  • So I solve this bug. I don't know why this bug appeared and I don't know why my fix work.

    In fact, I remove old code for the compatibility with iOS 5. This code used the objc/runtime.h library and its goal was to inject into all our UIViewController subclasses if they don't implement shouldAutorotateToInterfaceOrientation:

    We used this code to do that

    Method shouldAutorotateToInterfaceOrientation = class_getInstanceMethod([self class], @selector(shouldAutorotateToInterfaceOrientation:));
    class_addMethod(class, @selector(shouldAutorotateToInterfaceOrientation:), method_getImplementation(shouldAutorotateToInterfaceOrientation), method_getTypeEncoding(shouldAutorotateToInterfaceOrientation));