UIWebView acts differently in the app store version than the dev version

I have a problem with an application that works great on a simulator, as well as on a physical iPhone 4 and iPhone 3GS. The application was approved and is now in the App Store, but an error was found in the distribution downloaded from the App Store that was not noticed in the dev / release assembly.

This is a free application, but supported by local advertising. When the application starts (or returns from the background), AppDelegate tries to download some HTML from our ad server, and if successful, it is a modal view controller with UIWebView and passes the NSData variable containing HTML. In the development / release of the assembly, this works EXCELLENT; the application starts, and after a few seconds the presentation opens and shows an ad that can be released using the button.

However, the build from the app store is different. When the modal view controller has shifted, the UIWebView never loads. Remember, I present the view controller ONLY if you can upload the announcement data - otherwise the view will never be presented.

Fortunately, I implemented a timer in the ad review controller, which will cause the modal view to reject itself if webViewDidFinishLoad never fires (in which the timer is invalid), so at least application users are not too annoyed. But it's still ugly to have an empty view manager, and then crawl, apparently for no reason.

Here are the relevant methods in AppDelegate:

- (void)launchAd
{
    [NetworkActivity showFor:@"ad"];

    if (!alreadyActive && [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.");
}

By the way, adData is defined in the header with NSData *adData;

AdViewController simply contains a UIWebView that loads using

[webView loadData:adData MIMEType:@"text/html" textEncodingName:@"utf-8" baseURL:nil];

, , dev/release - . NSData NSString NSLog() , , HTML , AdView -.

[...]

1. , webViewDidFinishLoad ( dev/release).

2: , ,

[webView loadData:adData MIMEType:@"text/html" textEncodingName:@"utf-8" baseURL:nil];

AdViewController, NSLog() adData NSString , HTML. , UIWebView NSData?

+1
2

. .

, , , : , . , , , , . , , , , , .

... , , AdView.xib . , , , . - Xcode ( , ).

, AdView.xib . , . , , , ( , , , App Store).

, , , App Store ( ).

+2

, , , , .

docs NSData , initWithContentsOfURL " ". , , , :

adData = [[NSData alloc] initWithContentsOfURL:adURL];

adData - self.adData = . , , NSData : downloadAdData NSAutoreleasePool. . , adData , presentAdModal . ...

presentAdModal , adData , NSAutoreleasePool - , "show web view", NSData, . , , , , " -".

, , , .

UPDATE:

:

(.. -App-Store) (.. ), -, , - IP , App Store , . , , , .

0

Source: https://habr.com/ru/post/1796067/


All Articles