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.
- - (void)createAdBannerView
- {
- Class classAdBannerView = NSClassFromString(@"ADBannerView");
- if (classAdBannerView != nil)
- { ...
- }
- }
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.
- -(Void) viewDidLoad
- {
- [Self createAdBannerView];
- }
- -(Void) viewWillAppear :( BOOL) animated
- {
- [Self refresh];
- [Self fixupAdView: [UIDevice currentDevice]. orientation];
- }
- -(Void) willRotateToInterfaceOrientation :( UIInterfaceOrientation) toInterfaceOrientation
- Duration :( NSTimeInterval) duration
- {
- [Self fixupAdView: toInterfaceOrientation];
- }
-
- 4.5 implement ADBannerViewDelegate
-
- -(Void) bannerViewDidLoadAd :( ADBannerView *) banner
- {
- If (! _ AdBannerViewIsVisible)
- {
- _ AdBannerViewIsVisible = YES;
- [Self fixupAdView: [UIDevice currentDevice]. orientation];
- }
- }
- -(Void) bannerView :( ADBannerView *) banner didFailToReceiveAdWithError :( NSError *) error
- {
- If (_ adBannerViewIsVisible)
- {
- _ AdBannerViewIsVisible = NO;
- [Self fixupAdView: [UIDevice currentDevice]. orientation];
- }
- }
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