Note that there are some explanatory texts on larger screens.

plurals
  1. POUIWebView acts differnetly in app store version than dev version
    primarykey
    data
    text
    <p>I've got a problem with an app that works perfectly in the simulator as well as a physical iPhone 4 and an iPhone 3GS. The app was approved and is now in the App Store, but the distribution build downloaded from the App Store exhibits a bug not seen in the dev/release build.</p> <p>This is a free app, but is supported by local advertising. When the app launches (or returns from background), the AppDelegate attempts to download some HTML from our ad server, and if successful, presents a modal view controller with a UIWebView and passes an NSData variable containing the HTML. In development/release builds, this works PERFECTLY; the app launches, and after a few seconds, a view slides up and shows the ad, which can be dismissed with a button.</p> <p>However distribution build from the App Store is different. When the modal view controller slides up, the UIWebView never loads. Remember, I present the view controller ONLY if able to download the ad data -- otherwise, the view is never presented.</p> <p>Thankfully I implemented a timer in the ad view controller which will cause the modal view to dismiss itself if the webViewDidFinishLoad never fires (in which the timer is invalidated), so at least app users aren't too annoyed. But it's still ugly to have an empty view controller slide up and then slide away for apparently no reason.</p> <p>Here's the relevant methods in the AppDelegate:</p> <pre><code>- (void)launchAd { [NetworkActivity showFor:@"ad"]; if (!alreadyActive &amp;&amp; [ServerCheck serverReachable:@"openx.freewave-wifi.com" hideAlert:YES]) { alreadyActive = YES; [self performSelectorInBackground:@selector(downloadAdData) withObject:nil]; } [NetworkActivity hideFor:@"ad"]; } - (void)downloadAdData { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *baseURL = @"http://appdata.freewave-wifi.com/ad/"; NSString *file = (IS_IPAD) ? @"ipad.php" : @"iphone.php"; NSURL *adURL = [NSURL URLWithString:[baseURL stringByAppendingString:file]]; adData = [[NSData alloc] initWithContentsOfURL:adURL]; [self performSelectorOnMainThread:@selector(presentAdModal) withObject:nil waitUntilDone:NO]; [pool release]; } - (void)presentAdModal { if (adData) { AdViewController *adView = [[AdViewController alloc] initWithNibName:nil bundle:nil]; [adView setAdData:adData]; UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:adView]; [navController setModalPresentationStyle:UIModalPresentationFormSheet]; [navController setModalTransitionStyle:UIModalTransitionStyleCoverVertical]; [tabBarController presentModalViewController:navController animated:YES]; [navController release], navController = nil; [adView release], adView = nil; } else LogError(@"Not presenting ad; unable to create data object."); } </code></pre> <p>By the way, adData is defined in header with <code>NSData *adData;</code></p> <p>The AdViewController simply contains a UIWebView, which is loaded with</p> <pre><code>[webView loadData:adData MIMEType:@"text/html" textEncodingName:@"utf-8" baseURL:nil]; </code></pre> <p>Again, this all works PERFECTLY, EVERY TIME with dev/release builds in simulator and physical devices -- just not on distribution build from app store. I have even converted the NSData to an NSString and barfed it out with NSLog() just to prove that the HTML was downloaded before presenting the AdView modally.</p> <p>[sigh...]</p> <p><strong>EDIT 1</strong>: In case my original post was not clear, the <code>webViewDidFinishLoad</code> never gets called in distribution build (but it does in dev/release build).</p> <p><strong>EDIT 2</strong>: Also, just before I call</p> <pre><code>[webView loadData:adData MIMEType:@"text/html" textEncodingName:@"utf-8" baseURL:nil]; </code></pre> <p>in the AdViewController, I added a temporary <code>NSLog()</code> and converted adData to NSString and logged it to the console, and the HTML was there. So, the UIWebView just refuses to load the NSData?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload