user2721311
user2721311

Reputation: 21

AdBanner not showing in simulator

When I run the app in the simulator, all I get is a white window at the bottom of the screen which is where I placed the banner but then it disappears after 3 seconds...

This is the code I have in my .h file for iad:

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "CardScrollView.h"
#import <iAd/iAd.h>

@interface ViewController1 : UIViewController <CardScrollViewDelegate,
 ADBannerViewDelegate> {

}

@property (weak, nonatomic) IBOutlet ADBannerView *banner1;

@end

This is the code I have in my .m file for iad:

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.banner1.delegate = self;
}

- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner 
    willLeaveApplication:(BOOL)willLeave
{
    return YES;
}

- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1];
    [banner setAlpha:1];
    [UIView commitAnimations];
}

- (void)bannerView:(ADBannerView *)banner 
     didFailToReceiveAdWithError:(NSError *)error {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1];
    [banner setAlpha:0];
    [UIView commitAnimations];
}


@end

Note: I have two delegates in the .h file as shown above because I also have an UIScrollView on that same view controller. I don't have any errors or warnings so why isn't it showing up? This code works in my other apps.

Upvotes: 1

Views: 781

Answers (1)

Kalzem
Kalzem

Reputation: 7492

Had the same problem.

At some point, iAd stops working in simulator but works on real iPhones. And this happens without changing any line of code (of the iAd logic).

What I did to get it back to work :

  1. Go to the Application "Settings" of the Simulator (that means, run your app, click the Home button (or CMD+Shift+H), go to the first panel and find Settings)
  2. Go to Developer menu
  3. Set iAd to 100% fill rate

But this was not enough for me. Then I found a strange fix :

Let's say you were running the simulator for the iPhone Retina 4-inch, just select an other iPhone simulator like iPhone 3.5-inch or iPhone 4-inch 64 bit.

Somehow, this forces the iAd to appear once again !

Upvotes: 1

Related Questions