Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

iPhone Programming - How to implement iAds properly in Xcode

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
1,605
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Jun 21, 2011

A quick tutorial teaching you how to implement iAds into your app the proper way so it doesn't get rejected.

Main code used
In .h:
//Don't forget to add the iAd framework.
#import "iAd/iAd.h"
//Replace the " " with the left & right carrots.

@interface Test_iAdViewController : UIViewController "ADBannerViewDelegate" {




//Replace the " " with the left & right carrots. ADBannerView *aBanner;
}

@property (nonatomic, retain) IBOutlet ADBannerView *aBanner;
@property (nonatomic, assign) BOOL bannerIsVisible;

In the .m:
@synthesize aBanner,bannerIsVisible;

- (void)dealloc
{ [aBanner release]; [super dealloc];
}

//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; }
}

Twitter: http://twitter.com/failcakeapps
Apple Developer Center: http://developer.apple.com/devcenter/ios/index.action
Website: http://failcake.webs.com/
Channel: http://youtube.com/milmersxcode

  • likes, 2 dislikes

Link to this comment:

Share to:

Uploader Comments (MilmersXcode)

  • Great, great, great tutorial. Explains the coding and gives you some solutions to problems that might come up!

    Great work and thank you :)

    

  • @ckdixon3629 Glad I could help :D.

    Any questions just ask :D.

    Milmer.

  • i keep receiving the white box when the ad is not there. i dont know whats wrong. help!

  • @nikhilrukus I have noticed this a few times. I will investigate and hopefully solve the problem.

  • this code also works with multiple ads as well!

  • @robbydenicola Wow sorry for multiple post. YT failed.

see all

All Comments (17)

Sign In or Sign Up now to post a comment!
  • Really great tutorial

  • This is a great tutorial, but I've implemented the delegate and when it doesn't get internet connection, the ad just shows a blank screen.

  • @MilmersXcode

    I am also having the same problem...

    

  • @MilmersXcode I appreciate this, please reply back if any input

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more