0

I want to integrate native express ads in my project. And I want to bind this ads in tableview, but I'm not able to display.

I'm using this below code:

#pragma mark - UITableViewDataSource
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{
    return 150;
}
// number of section(s), now I assume there is only 1 section
- (NSInteger)numberOfSectionsInTableView:(UITableView *)theTableView
{
    return 1;
}

// number of row in the section, I assume there is only 1 row
- (NSInteger)tableView:(UITableView *)theTableView numberOfRowsInSection:(NSInteger)section
{
    return 10;
}
- (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"HistoryCell";

    // Similar to UITableViewCell, but
    customcell *cell = (customcell *)[theTableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[customcell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
        dispatch_async(dispatch_get_main_queue(), ^{
        [cell cellNativeAds:self];
    })
    return cell;
}

This is my custom cell:

-(void)cellNativeAds:(UIViewController*)rootVC {
    self.nativeExpressAdView.adUnitID = @"ca-app-pub-404901943dsdsd4086773/3124124124";
    self.nativeExpressAdView.rootViewController = rootVC;
    self.nativeExpressAdView.delegate = self;

    // The video options object can be used to control the initial mute state of video assets.
    // By default, they start muted.
    GADVideoOptions *videoOptions = [[GADVideoOptions alloc] init];
    videoOptions.startMuted = true;
    [self.nativeExpressAdView setAdOptions:@[videoOptions]];

    // Set this UIViewController as the video controller delegate, so it will be notified of events
    // in the video lifecycle.
    self.nativeExpressAdView.videoController.delegate = self;

    GADRequest *request = [GADRequest request];
    [self.nativeExpressAdView loadRequest:request];


}
halfer
  • 19,824
  • 17
  • 99
  • 186
Yogendra Patel
  • 813
  • 2
  • 8
  • 24

1 Answers1

0

Finally I reached to solution :) this is demo link

Yogendra Patel
  • 813
  • 2
  • 8
  • 24