Integrate iAd ads in iPhone apps

Source: Internet
Author: User

InIPhoneProgram IntegrationIAdAdvertisement is the content to be introduced in this article,IAdThe launchIphone/IPad app developers opened another revenue-generating door. Not long ago, a developer in the United States, Json Ting, developed an application to convert the camera flash into a flashlight, integratedIAdThen, on the first day, he was given an advertising revenue of $1400. In this article, I will explain howIAdIntegrate into your application. Some integration problems may also be mentioned:

How to support landscape and landscape screens.

How to maintain backward compatibility with OS 3.0.

Integration with UITableViewController.

1. Set Base SDK to 4.0 and Deployment target to 3.0 .:

2. Link iAd Framework.

Right-click Frameworks, select Add \ Existing Frameworks, and Add iAd. framework ". but in the absence of iAd. for example, 3. in Version x, Crash. so we need to change this link to weak link. in "targets", right-click your project, and then "Get Info", and add "-weak_framework iAd" to Linking \ Other Linker Flags ". this ensures program backward compatibility.

3. Add your UI to XIB

You can consider adding other functional UIS to a parent UIView. The iAd and the parent UIView are used as the same level later, so that the original UI is not affected when the iAd is displayed.

4. Integration with UIViewController

1) obtain the help function of the iAd Banner size (see the example ).

2) create an iAd Banner function.

 
 
  1. - (void)createAdBannerView   
  2.  {  
  3.     Class classAdBannerView = NSClassFromString(@"ADBannerView");   
  4.    if (classAdBannerView != nil)   
  5.     { ...  
  6.     }  

NSClassFromString can be used to ensure code backward compatibility. On OS 3. x systems, this function will not succeed, iAd will not be displayed, but the program can still run.

4) function for adjusting the functional UI and the position of the iAd Banner. (See the sample code fixupAdView)

5) Create and adjust the position of the iAd Banner at the right time.

 
 
  1. -(Void) viewDidLoad
  2. {
  3. [Self createAdBannerView];
  4. }
  5. -(Void) viewWillAppear :( BOOL) animated
  6. {
  7. [Self refresh];
  8. [Self fixupAdView: [UIDevice currentDevice]. orientation];
  9. }
  10. -(Void) willRotateToInterfaceOrientation :( UIInterfaceOrientation) toInterfaceOrientation
  11. Duration :( NSTimeInterval) duration
  12. {
  13. [Self fixupAdView: toInterfaceOrientation];
  14. }
  15.  
  16. 4.5 implement ADBannerViewDelegate
  17.  
  18. -(Void) bannerViewDidLoadAd :( ADBannerView *) banner
  19. {
  20. If (! _ AdBannerViewIsVisible)
  21. {
  22. _ AdBannerViewIsVisible = YES;
  23. [Self fixupAdView: [UIDevice currentDevice]. orientation];
  24. }
  25. }
  26. -(Void) bannerView :( ADBannerView *) banner didFailToReceiveAdWithError :( NSError *) error
  27. {
  28. If (_ adBannerViewIsVisible)
  29. {
  30. _ AdBannerViewIsVisible = NO;
  31. [Self fixupAdView: [UIDevice currentDevice]. orientation];
  32. }
  33. }

5. Integration with UITableViewController (updating)

Sample Code

Summary: InIPhoneProgram IntegrationIAdI hope this article will help you with the introduction of the advertisement content.

From: http://www.cnblogs.com/MobileDevelop/archive/2010/07/17/1779133.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.