Question

Once upon a time there was an iAd Banner who worked perfectly. One day it decided to cause EXC_BAD_ACCESS whenever it was tapped for no apparent reason.

So I'm working on a little iOS game that has an iAd Banner at the top of the screen. When bannerViewActionShouldBegin: willLeaveApplication: is called I send an NSNotification to pause the game, then I return TRUE. It used to work as expected, until 2 days ago when tapping the banner started causing EXC_BAD_ACCESS

The relevant code relating to the banner is thus:

Header:

@interface JAGameBackground : UIView <ADBannerViewDelegate>
{
    ...
    ADBannerView *adBannerView;
}

Main:

+(id)gameView
{
    JAGameBackground *aBackground = [[JAGameBackground alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height + [UIScreen mainScreen].bounds.size.width)];

    aBackground.adBannerView = [[ADBannerView alloc] initWithFrame:CGRectZero];
    aBackground.adBannerView.delegate = aBackground;
    [aBackground addSubview:aBackground.adBannerView];
...
   return aBackground;
}

-(BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{
    [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_PAUSE object:nil];
    return TRUE;
}

And running it with Instruments: NSZombie in Instruments

Any ideas on how to give this issue a fairy-tale ending?

Was it helpful?

Solution

Turns out I had made the mistake of not loading the iAd Banner (along with other UIKit objects) on the main thread...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top