iOS 7 UIWebView not rendering

11,475

Solution 1

As mentioned by @zaplitny, I had to update Crittercism to the latest version (4.1.0) for this problem to go away.

Solution 2

There was a problem with older version of the Crittercism library which caused this. As others have alluded to in comments, this bug was fixed in the 4.3.1 version of the Crittercism SDK.

https://app.crittercism.com/downloads/release_notes/ios/4.3.1 :

fix: Workaround for apps experiencing UIWebViews failing to load data on first launch when running on iOS 7. This only occurs in apps that subclass UIWebView, and Crittercism has filed a bug report with Apple. Note - Be aware that while your application may not directly subclass UIWebView, this is done in many common 3rd party libraries such as the Google AdMob and Millenial Media SDKs.

Solution 3

For those of us who updated Crittercism to the version 4.1.2 hoping that it would solve the issue but it didn't. I can offer quite an ugly but simple solution: create and initialize UIWebView before calling [Crittercism enableWithAppID:@"***...***"];

- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
    ...
    UIWebView* fakeWebView = [[[UIWebView alloc] initWithFrame:CGRectMake(-1, -1, 1, 1)] autorelease];
    [fakeWebView loadHTMLString:@"<!DOCTYPE HTML><html><body>I need Crittercism</body></html>" baseURL:nil];
    [mainViewController.view addSubview:fakeWebView];

    [Crittercism enableWithAppID:@"***...***"];
    ...
}

This trick allowed me not only to get rid of a described problem, but also slightly speed up the first initialization of a real UIWebView.

Solution 4

I had this error appearing trying to display admob ads, when ever crittercism was enabled I would get that error in the logs, incidentally the ads were not displaying either.

To fix it, I disabled crittercism instrumentation, this might not be an option for everyone.

[Crittercism enableWithAppID:@"your_app_id" andDelegate:nil andURLFilters:nil disableInstrumentation:YES];

If not simply creating a webview (You don't need to add it as a subview) as suggested by others seems to work for me as well.

[[UIWebView alloc] initWithFrame:CGRectMake(-1, -1, 1, 1)]
[Crittercism enableWithAppID:@"your_app_id"];

Solution 5

Try product --> clean. It can't hurt. When you run an app it will only replace/compile the files that changed. Some times the xCode bugs up and doesn't compile a changed file. Product clean deletes old versions of the compiled code so next time you build it will have been all from the last compile. Again you have nothing to lose by doing it.

Share:
11,475
usakc
Author by

usakc

Updated on June 24, 2022

Comments

  • usakc
    usakc almost 2 years

    I'm porting my app to iOS 7 and I have a problem with UIWebView in iOS 7. I load local html string in it with this code:

    NSURL *baseURL = [NSURL fileURLWithPath: DOCUMENTS_DIRECTORY];
    [self.descWebView loadHTMLString:html baseURL:baseURL];
    

    It works perfectly on iOS 6 and prior but on iOS 7 it doesn't rendering and the UIWebView is still white. And this message appears in console:

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

    Thanks for your replies.