I have an iAd banner view, with all my contracts up and running, and I've implemented the ADBannerView
delegate. The banner should disappear with no internet connection, but it just shows a white box where the content should be. I know I have all the code right, I've seen a million tutorials on this. So I ran some tests and found that the banner view wasn't even calling the two methods for the delegate! Here is the code.
In the .h file:
#import <iAd/iAd.h>
@interface DetailViewController : ADBannerViewDelegate>
{
ADBannerView *aBanner;
BOOL bannerIsVisible;
}
@property (nonatomic, retain) IBOutlet ADBannerView *aBanner;
@property (nonatomic, assign) BOOL bannerIsVisible;
@end
in the .m file:
@implementation DetailViewController
@synthesize aBanner,bannerIsVisible;
//Show banner if can load ad.
-(void)bannerViewDidLoadAd:(ADBannerView *)banner
{
if (!self.bannerIsVisible) {
[UIView beginAnimations:@"animateAdBannerOn" context:NULL]; banner.frame = CGRectOffset(banner.frame, 0, -banner.frame.size.height);
[UIView commitAnimations]; self.bannerIsVisible = YES; }
}
//Hide banner if can't load ad.
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
if (self.bannerIsVisible) {
[UIView beginAnimations:@"animateAdBannerOff" context:NULL]; banner.frame = CGRectOffset(banner.frame, 0, banner.frame.size.height);
[UIView commitAnimations]; self.bannerIsVisible = NO; }
}