0

我想在我的项目中集成原生快递广告。我想在tableview中绑定这个广告,但我无法显示。

我正在使用以下代码:

#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;
}

这是我的自定义单元格:

-(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];


}
4

1 回答 1

0

最后我找到了解决方案:) 这是演示 链接

于 2017-01-19T04:34:02.680 回答