Horizontal Scroll View

Creates a horizontal ad scroll view leveraging the native ads manager and either a native ad template or publisher defined UI view.

Implementation

Before you start, if you haven't done so yet, follow the steps in our getting started guide to set up the SDK.

Initialize the Audience Network SDK and load ads via the native ads manager:

- (void)viewDidLoad {
  [super viewDidLoad];

  FBNativeAdsManager *manager = [[FBNativeAdsManager alloc] initWithPlacementID:@"YOUR_PLACEMENT_ID" forNumAdsRequested:5];
  manager.delegate = self;
  [manager loadAds];
  self.manager = manager;
}

Render FBNativeAdScrollView by providing a loaded NativeAdsManager and a native ad template or publisher defined UI View via the native ads api:

- (void)nativeAdsLoaded
{
  NSLog(@"Native ads loaded, constructing native UI...");
  if (self.scrollView) {
    [self.scrollView removeFromSuperview];
    self.scrollView = nil;
  }
  FBNativeAdScrollView *scrollView = [[FBNativeAdScrollView alloc] initWithNativeAdsManager:self.manager withType:FBNativeAdViewTypeGenericHeight300];
  scrollView.delegate = self;
  scrollView.frame = self.containerView.bounds;
  [self.containerView addSubview:scrollView];
  self.scrollView = scrollView;
}