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
Great, great, great tutorial. Explains the coding and gives you some solutions to problems that might come up!
Great work and thank you :)
ckdixon3629 2 months ago
@ckdixon3629 Glad I could help :D.
Any questions just ask :D.
Milmer.
MilmersXcode 2 months ago
i keep receiving the white box when the ad is not there. i dont know whats wrong. help!
nikhilrukus 2 months ago
@nikhilrukus I have noticed this a few times. I will investigate and hopefully solve the problem.
MilmersXcode 2 months ago
this code also works with multiple ads as well!
robbydenicola 5 months ago in playlist Basic iPhone Programming Tutorials
@robbydenicola Wow sorry for multiple post. YT failed.
MilmersXcode 5 months ago