iAds not hiding - iphone

I have IBOutlet on bottom of the screen for ADBannerView, and I won't to hide it when it shows white screen (not able to load an Ad).
I have this code, but it is not working:
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
[UIView beginAnimations:#"showAd" context:nil];
CGRect adBannerViewFrame = [bannerView frame];
adBannerViewFrame.origin.x = 160;
adBannerViewFrame.origin.y = 523;
bannerView.frame = adBannerViewFrame;
[UIView commitAnimations];
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
[UIView beginAnimations:#"hideAd" context:nil];
CGRect adBannerViewFrame = [bannerView frame];
adBannerViewFrame.origin.x = 0;
adBannerViewFrame.origin.y = 0;
bannerView.frame = adBannerViewFrame;
[UIView commitAnimations];
}
Can you help me please, I'm struggling with it for past two hours... :/

you should try something like this (this is from a live project). the iAd banner is at the bottom of the screen and it goes down when it becomes invisible, and it comes up back when it must be visible.
the _isiADBannerVisible is just a simple Boolean variable.
- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
if (_isiADBannerVisible == false) {
_isiADBannerVisible = true;
[UIView animateWithDuration:0.5f delay:0.f options:UIViewAnimationCurveEaseInOut animations:^{
[banner setFrame:CGRectOffset(banner.frame, 0.f, -50.f)];
} completion:nil];
}
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
if (_isiADBannerVisible == true) {
_isiADBannerVisible = false;
[UIView animateWithDuration:0.5f delay:0.f options:UIViewAnimationCurveEaseInOut animations:^{
[banner setFrame:CGRectOffset(banner.frame, 0.f, +50.f)];
} completion:nil];
}
}

Related

iAd is not loading in iPhone but loading in iPad after approval from apple

I have developed an application which recently approved from apple. But problem is iAd is not showing in iphone where as in ipad iAd is showing perfectly. At the time of development iAd is loaded and worked with test advertisement in both iPhone and iPad. But after approval from apple i have downloaded application from store noticed that iAd is not loading in iphone but it was loading in ipad. I have check other application in iphone in other application iAd is working fine but in my application iAd is not loading. So what should i do now to load the iAd in iphone.
My code that i used in the application was
-(void)showiAdInView
{
if (!appDelegate.isUpgraded) {
bannerView = [[ADBannerView alloc] init];
bannerView.delegate = self;
bannerView.backgroundColor = [UIColor colorWithWhite:1.0f alpha:0.005f];
bannerView.hidden = TRUE;
bannerIsVisible = FALSE;
[self.view addSubview:bannerView];
}
}
-(void)bannerViewDidLoadAd:(ADBannerView *)banner
{
bannerIsVisible = YES;
bannerView.hidden = FALSE;
NSLog(#"ADBanner is Showing");
[self bannerViewShow];
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
bannerIsVisible = FALSE;
bannerView.hidden = TRUE;
NSLog(#"ADBanner is Hidding");
NSLog(#"%#",[error description]);
[self bannerViewHide];
}
-(BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication: (BOOL)willLeave
{
if ([self.captureSession isRunning]) {
[self.captureSession stopRunning];
iAdLoaded = TRUE;
}
return YES;
}
-(void)bannerViewActionDidFinish:(ADBannerView *)banner
{
UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
[self willRotateToInterfaceOrientation:interfaceOrientation duration:0.2f];
if (![self.captureSession isRunning] && iAdLoaded) {
[self.captureSession startRunning];
iAdLoaded = FALSE;
}
}
-(void)bannerViewShow
{
[bannerView setBackgroundColor:[UIColor colorWithWhite:1.0f alpha:0.005f]];
UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[MsgtextView setFrame:MsgTextVwAdBannerFrame];
[UIView commitAnimations];
adBannerFrame = CGRectMake(0, 190, 320, 50);
clearButton.frame = CGRectMake(ClearButtonFramePotrait.origin.x, ClearButtonFramePotrait.origin.y, ClearButtonFramePotrait.size.width, ClearButtonFramePotrait.size.height);
[self.view bringSubviewToFront:bannerView];
[bannerView setFrame:adBannerFrame];
[bannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierPortrait];
}
else if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[MsgtextView setFrame:CGRectMake(MsgTextVwAdBannerFrame.origin.x, MsgTextVwAdBannerFrame.origin.y, MsgTextVwAdBannerFrame.size.width, MsgTextVwAdBannerFrame.size.height+8)];
[UIView commitAnimations];
adBannerFrame = CGRectMake(0, 105, 470, 32);
clearButton.frame = CGRectMake(ClearButtonFrameLandscape.origin.x, ClearButtonFrameLandscape.origin.y, ClearButtonFrameLandscape.size.width, ClearButtonFrameLandscape.size.height);
[bannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierLandscape];
[self.view bringSubviewToFront:bannerView];
[bannerView setFrame:adBannerFrame];
}
}
else if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[MsgtextView setFrame:MsgTextVwAdBannerFrame];
[UIView commitAnimations];
adBannerFrame = CGRectMake(0, 640, 768, 50);
[bannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierPortrait];
clearButton.frame = CGRectMake(ClearButtonFrame_iPadPotrait.origin.x, ClearButtonFrame_iPadPotrait.origin.y, ClearButtonFrame_iPadPotrait.size.width, ClearButtonFrame_iPadPotrait.size.height);
[self.view bringSubviewToFront:bannerView];
[bannerView setFrame:adBannerFrame];
}
else if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[MsgtextView setFrame:CGRectMake(MsgTextVwAdBannerFrame.origin.x, MsgTextVwAdBannerFrame.origin.y, MsgTextVwAdBannerFrame.size.width, MsgTextVwAdBannerFrame.size.height+8)];
[UIView commitAnimations];
adBannerFrame = CGRectMake(0, 325, 1024, 32);
[bannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierLandscape];
clearButton.frame = CGRectMake(ClearButtonFrame_iPadPotrait.origin.x, ClearButtonFrame_iPadPotrait.origin.y, ClearButtonFrame_iPadPotrait.size.width, ClearButtonFrame_iPadPotrait.size.height);
[self.view bringSubviewToFront:bannerView];
[bannerView setFrame:adBannerFrame];
}
}
}
-(void)bannerViewHide
{
[bannerView setBackgroundColor:[UIColor clearColor]];
UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[MsgtextView setFrame:MsgTextVwFrame];
clearButton.frame = ClearButtonFramePotrait;
[bannerView setHidden:YES];
[UIView commitAnimations];
}
else if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[MsgtextView setFrame:MsgTextVwFrame];
clearButton.frame = ClearButtonFrameLandscape;
[bannerView setHidden:YES];
[UIView commitAnimations];
}
}
else if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[MsgtextView setFrame:MsgTextVwFrame];
clearButton.frame = ClearButtonFrame_iPadPotrait;
[bannerView setHidden:YES];
[UIView commitAnimations];
}
else if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[MsgtextView setFrame:MsgTextVwFrame];
clearButton.frame = ClearButtonFrame_iPadPotrait;
[bannerView setHidden:YES];
[UIView commitAnimations];
}
}
}
iAd, overall, has a pretty low fill rate. Ad networks (iAd included) send you more ads the better your click-through-rate is; ie., the ratio of users who click ads in your app : ads you display in your app. If you have confirmed test ads were working and you've just released the app, it's entirely possibly it's just taking a little while for Apple to send you ad fils on the iPhone build. Give it a couple days and see how it goes.
Alternately, I notice your 'isUpgraded' code, there--is it possible that, on the iPhone you're testing on, you purchased the upgrade and forgot, and are now no longer returning ads?

xcode 4.3 - storyboard - iAd keeps moving

I have added iAd to my iphone app to be at the top of my app. originally I place it at x=0 and y=-50 so that it comes from off the screen. I use the following code for it in my .m :
- (void)bannerView:(ADBannerView *)abanner didFailToReceiveAdWithError:(NSError *)error
{
if (self.bannerIsVisible)
{
[UIView beginAnimations:#"animateAdBannerOff" context:NULL];
// Assumes the banner view is placed at the bottom of the screen.
banner.frame = CGRectOffset(banner.frame, 0, banner.frame.size.height);
[UIView commitAnimations];
self.bannerIsVisible = NO;
}
}
- (void)bannerViewDidLoadAd:(ADBannerView *)abanner
{
if (!self.bannerIsVisible)
{
[UIView beginAnimations:#"animateAdBannerOn" context:NULL];
// Assumes the banner view is just off the bottom of the screen.
banner.frame = CGRectOffset(banner.frame, 0, banner.frame.size.height);
[UIView commitAnimations];
self.bannerIsVisible = YES;
}
}
When my app launch iAd get displayed at the top without any problem. but when I open another app and come back to it (without killing it so my app is running in the background) the banner moves another 50 pixel down
any idea?
You are adding 50.0px to banner.frame.origin.y in both cases.
Anyway: even if you'd be substracting 50.px in didFailToReceiveAdWithError: it
could happen that didFailToReceiveAdWithError: would get called multiple times in a
row and your code could move the banner higher and higher up (-50.0,-100.0,-150.0...).
So it's better to hardcode the hidden & visible positions instead of calculating it.
Try this:
- (void)bannerView:(ADBannerView *)abanner didFailToReceiveAdWithError:(NSError *)error
{
if (self.bannerIsVisible)
{
[UIView beginAnimations:#"animateAdBannerOff" context:NULL];
banner.frame = CGRectMake(0.0,-50.0,banner.frame.size.width,banner.frame.size.height);
[UIView commitAnimations];
self.bannerIsVisible = NO;
}
}
- (void)bannerViewDidLoadAd:(ADBannerView *)abanner
{
if (!self.bannerIsVisible)
{
[UIView beginAnimations:#"animateAdBannerOn" context:NULL];
banner.frame = CGRectMake(0.0,0.0,banner.frame.size.width,banner.frame.size.height);
[UIView commitAnimations];
self.bannerIsVisible = YES;
}
}

How to make two view animations run one by one?

I am to make "Guess match card" game, that is :there are 24 cards(UIImageView) in the windows with hide inside view shown surface, They a 12 groups number,you touch one, then it will be open show inside,find if there has a same card opened, if not matched, two opened card will then hide.
Just this.
open card and hide card action used UIView animation. But now I have a problem.when I touched card, it then try to find if there has a match. But open card and close card action animation execute at same time. even I can't see what card content I see clear.
I want to open a card after I touch it, then (even wait for 0.5 second) close the opend not matched cards at same time. not open card and close card at same time. But in my code below I did open a card first,then compute, and close two opend card then.
#interface Card : UIImageView
#property BOOL expanded;
#property BOOL found;
#property (retain)NSString * nameTitle;
#property (retain) UIImage * expandedImage;
#end
//
// Card.m
// Guest card match
//
// Created by on 11-10-20.
// Copyright 2011年 __MyCompanyName__. All rights reserved.
//
#import "Card.h"
#import "MainAppDelegate.h"
#implementation Card
#synthesize expanded;
#synthesize found;
#synthesize expandedImage;
#synthesize nameTitle;
- (id)init
{
if ((self = [super init])) {
[self setUserInteractionEnabled:YES];
self.image = [UIImage imageNamed:#"cardface_48.png"];
self.expanded = NO;
self.found = NO;
}
return self;
}
- (void)openCard{
NSLog(#"open card");
if (self.expanded){return;}
self.expanded = YES;
[UIView beginAnimations:#"animation1" context:nil];
[UIView setAnimationDuration:0.8];
[UIView setAnimationDelegate:self];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self cache:YES];
[self setTransform:CGAffineTransformMakeScale(3.0, 3.0)];
[self setImage:self.expandedImage];
[UIView commitAnimations];
[UIView beginAnimations:#"animation1_open" context:nil];
[UIView setAnimationDuration:1.2];
[UIView setAnimationDelegate:self];
[UIView setAnimationBeginsFromCurrentState:NO];
[self setTransform:CGAffineTransformMakeScale(1, 1)];
[UIView commitAnimations];
}
- (void)closeCard{
if (!self.expanded){return;}
self.expanded = NO;
[UIView beginAnimations:#"animation1_close" context:nil];
[UIView setAnimationDuration:0.8];
[UIView setAnimationDelegate:self];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self cache:YES];
[self setTransform:CGAffineTransformMakeScale(3.0, 3.0)];
[self setImage:[UIImage imageNamed:#"cardface_48.png"]];
[UIView commitAnimations];
[UIView beginAnimations:#"animation2_close" context:nil];
[UIView setAnimationDuration:1.2];
[UIView setAnimationDelegate:self];
[UIView setAnimationBeginsFromCurrentState:NO];
[self setTransform:CGAffineTransformMakeScale(1, 1)];
[UIView commitAnimations];
[self setUserInteractionEnabled:YES];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
// Do what you want here
//NSLog(#"touchesBegan!");
//[self setUserInteractionEnabled:NO];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(#"card tag: %d", self.tag);
if (self.expanded) {
return;
}
[self openCard];
for (NSInteger tagNumber=10001; tagNumber<10025; tagNumber++) {
Card *card = (Card *)[self.superview viewWithTag:tagNumber];
if (card.expanded && card.tag != self.tag && !card.found) {
if ([card.nameTitle isEqualToString:self.nameTitle]) {// Found match!
NSLog(#"Match!");
[card setUserInteractionEnabled:NO];
[self setUserInteractionEnabled:NO];
card.found = YES;
self.found = YES;
}else{
NSLog(#"not Match!");
[card closeCard];
[self closeCard];
}
}else{
[self setUserInteractionEnabled:YES];
}
}
}
#end
Update: I followed Kashiv, and this updated code:
- (void)openCard{
NSLog(#"open card");
if(cardAnimationIsActive) return;
cardAnimationIsActive = YES;
if (self.expanded){return;}
self.expanded = YES;
[UIView animateWithDuration:2.0f animations:^{
[UIView beginAnimations:#"animation1" context:nil];
[UIView setAnimationDuration:0.8];
[UIView setAnimationDelegate:self];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self cache:YES];
[self setTransform:CGAffineTransformMakeScale(3.0, 3.0)];
[self setImage:self.expandedImage];
[UIView commitAnimations];
[UIView beginAnimations:#"animation1_open" context:nil];
[UIView setAnimationDuration:1.2];
[UIView setAnimationDelegate:self];
[UIView setAnimationBeginsFromCurrentState:NO];
[self setTransform:CGAffineTransformMakeScale(1, 1)];
[UIView commitAnimations];
} completion:^(BOOL finished){
cardAnimationIsActive = NO;
}];
}
- (void)closeCard{
if(cardAnimationIsActive) return;
cardAnimationIsActive = YES;
if (!self.expanded){return;}
self.expanded = NO;
[UIView animateWithDuration:5.0f animations:^{
[UIView beginAnimations:#"animation1_close" context:nil];
[UIView setAnimationDuration:0.8];
[UIView setAnimationDelegate:self];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self cache:YES];
[self setTransform:CGAffineTransformMakeScale(3.0, 3.0)];
[self setImage:[UIImage imageNamed:#"android_48.png"]];
[UIView commitAnimations];
[UIView beginAnimations:#"animation2_close" context:nil];
[UIView setAnimationDuration:1.2];
[UIView setAnimationDelegate:self];
[UIView setAnimationBeginsFromCurrentState:NO];
[self setTransform:CGAffineTransformMakeScale(1, 1)];
[UIView commitAnimations];
[self setUserInteractionEnabled:YES];
} completion:^(BOOL finished){
cardAnimationIsActive = NO;
}];
}
But opencard and closecard animation still execute at same time.
You can acheive this by using block-based animation:
+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion
Then you can check if animation is still executing or is finished bu using BOOL iVar (e.g. cardAnimationIsActive).
Example:
- (void)openCard {
if(cardAnimationIsActive) return;
cardAnimationIsActive = YES;
[UIView animateWithDuration:duration animations:^{
--- your open animations ---
} completion:^(BOOL finished){
cardAnimationIsActive = NO;
}];
}
- (void)closeCard {
if(cardAnimationIsActive) return;
cardAnimationIsActive = YES;
[UIView animateWithDuration:duration animations:^{
--- your close animations ---
} completion:^(BOOL finished){
cardAnimationIsActive = NO;
}];
}
You could use:
[UIView setAnimationDelay:delay];
to delay all animations the proper time so they run in sequence.
[UIView animateWithDuration:0.2
animations:^{view.alpha = 0.0;}
completion:^(BOOL finished){ [view removeFromSuperview]; }];
You can create second animation in completion block.

iAd - not working properly

I'm adding iAd on my app.... I managed to have the banner sliding from the bottom (just above my tab bar, 0, 410 i guess)... but only when i launch the app the first time. when then i try to switch the wifi off on my testing device to check if i get the blank banner i get the following message:ADBannerView: WARNING A banner view (0x1b11d0) has an ad but may be obscured. This message is only printed once per banner view. Can please somebody help me??
-(void)bannerViewDidLoadAd:(ADBannerView *)banner{
if (!self.bannerIsVisible) {
[UIView beginAnimations:#"animatedAdBannerOn" context:NULL];
NSLog(#"there are ads to show");
banner.frame = CGRectOffset(banner.frame, 0, -50);
[UIView commitAnimations];
self.bannerIsVisible = YES;
}
}
//----hide banner if can't load ad.
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
if (!self.bannerIsVisible) {
[UIView beginAnimations:#"animatedAdBannerOff" context:NULL];
NSLog(#"sorry, no ads ");
banner.frame = CGRectOffset(banner.frame, 0, 410);
[UIView commitAnimations];
self.bannerIsVisible = NO;
}
}
- (void)viewDidLoad {
[super viewDidLoad];
aBanner = [[ADBannerView alloc]initWithFrame:CGRectZero];
aBanner.frame = CGRectOffset(aBanner.frame, 0, 410);
aBanner.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
aBanner.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
[self.view addSubview:aBanner];
aBanner.delegate=self;
self.bannerIsVisible=NO;
[super viewDidLoad];
I know something is wrong in the CGRectOffset but I'm not able to figure it out.
thanks
FIND THE PROBLEM.... WAS JUST A SIMPLE "!" HERE THE CODE FIXED:
-(void)bannerViewDidLoadAd:(ADBannerView *)banner{
if (!self.bannerIsVisible) {
[UIView beginAnimations:#"animatedAdBannerOn" context:NULL];
NSLog(#"there are ads to show");
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) { //THE PROBLEM WAS HERE!!!!
[UIView beginAnimations:#"animatedAdBannerOff" context:NULL];
NSLog(#"sorry, no ads ");
banner.frame = CGRectOffset(banner.frame, 0, banner.frame.size.height);
[UIView commitAnimations];
self.bannerIsVisible = NO;
}
}
- (void)viewDidLoad {
[super viewDidLoad];
aBanner = [[ADBannerView alloc]initWithFrame:CGRectZero];
aBanner.frame = CGRectOffset(aBanner.frame, 0, 410);
aBanner.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
aBanner.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
[self.view addSubview:aBanner];
aBanner.delegate=self;
self.bannerIsVisible=NO;
[super viewDidLoad];

Hide iAds on iPhone when there is no network connection

I am trying to include iAds in my app. It works fine when there is network connection but the iAds doesn't hide when the network is not available..please find the code below and help me..thanks for your time..
I included this code in viewDidLoad
static NSString * const kADBannerViewClass = #"ADBannerView";
if (NSClassFromString(kADBannerViewClass) != nil) {
if (self.adView == nil) {
self.adView = [[[ADBannerView alloc] init] autorelease];
self.adView.delegate = self;
self.adView.frame = CGRectMake(0,355,320,60);
self.adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
}
}
[self.view addSubview:self.adView];
Delegate methods:
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
if (!self.bannerIsVisible) {
[UIView beginAnimations:nil context:NULL];
banner.frame = CGRectOffset(banner.frame, 0,10);
[UIView commitAnimations];
self.bannerIsVisible = YES;
}
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
if (self.bannerIsVisible) {
[UIView beginAnimations:nil context:NULL];
banner.frame = CGRectOffset(banner.frame, 0, -10);
[UIView commitAnimations];
self.bannerIsVisible = NO;
NSLog(#"%#",error);
}
}
If I understand your code correctly, you are initially showing the banner. That is not correct. It is better to initially move the banner off-screen and then only move it on-screen when you receive bannerViewDidLoadAd: and back off-screen when you receive bannerView:didFailToReceiveAdWithError:.
This also has the advantage that your banner view does not initially show up empty. Which can happen if there is a slow network connection.
You can do like this
Hide banner during viewdidload and write this in .m file.
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
NSLog(#"Error loading iAd");
}
-(void)bannerViewDidLoadAd:(ADBannerView *)banner{
NSLog(#"Ad loaded");
self.banner.hidden = NO;
}
-(void)bannerViewWillLoadAd:(ADBannerView *)banner{
NSLog(#"Ad will load");
self.banner.hidden = NO;
}
-(void)bannerViewActionDidFinish:(ADBannerView *)banner{
NSLog(#"Ad did finish");
self.banner.hidden = NO;
}