0 min.

Leave a Reply

Your email address will not be published. Required fields are marked *

// Import the SDK header file and declare that you are implementing // the FBAdViewDelegate protocol: #import @interface MyViewController : UIViewController // Other code might go here... @end // In your View Controller, create a new instance of the FBAdView // and add it to your view hierarchy: - (void)viewDidLoad { [super viewDidLoad]; FBAdView *adView = [[FBAdView alloc] initWithPlacementID:@"160963337672507_254657064969800" adSize:kFBAdSize320x50 rootViewController:self]; adView.delegate = self; [adView loadAd]; // Reposition the adView // ... [self.view addSubview:adView]; } // Now that you have the basic code running, it is recommended that you use // the FBAdView delegate to get notified when the ad fails to load so you // could hide the banner unit. In the same way, you can add it back when it // was loaded: - (void)adView:(FBAdView *)adView didFailWithError:(NSError *)error; { NSLog(@"Ad failed to load"); // Add code to hide the ad unit... // E.g. adView.hidden = YES; } - (void)adViewDidLoad:(FBAdView *)adView; { NSLog(@"Ad was loaded and ready to be displayed"); // Add code to show the ad unit... // E.g. adView.hidden = NO; }