1

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.

Wayne Koorts
  • 10,861
  • 13
  • 46
  • 72
user2721311
  • 21
  • 1
  • 5
  • I met this issue too. Seems it only affect on simulator but works good on real phone. – Shuduo Aug 27 '13 at 17:10
  • You should put a log in the `bannerView: didFailToReceiveAdWithError:` `NSLog (@"%@",error);` – ppaulojr Aug 27 '13 at 18:25
  • @ppaulojr how do i put that log for that? and to "shuduo" im yet to try this on a phone but when i do i will update everybody as to whether it works though its odd because this iad code works in my other apps – user2721311 Aug 27 '13 at 20:20
  • - (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:1]; [banner setAlpha:0]; [UIView commitAnimations]; NSLog (@"%@",error); } – ppaulojr Aug 27 '13 at 20:41

1 Answers1

1

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 !

Kalzem
  • 7,320
  • 6
  • 54
  • 79