Multiple GADBannerView in UiCollectionView is not scrolling smoothly in Objective C

122 Views Asked by At

I have a collection view in my project with lots of data coming from a web service, with GADBAnnerView(AdMob) on every 4th position. Ads are showing but it doesn't scroll smoothly.

- (void)preloadNextGoogleBannerAd {
if (!adMobBannersToLoad.count) {
    return;
}
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){
    GADBannerView *adView = adMobBannersToLoad.firstObject;
    [adMobBannersToLoad removeObjectAtIndex:0];
    GADRequest *request = [GADRequest request];
    request.testDevices = @[ kGADSimulatorID ];
    dispatch_async(dispatch_get_main_queue(), ^(void){
       [adView loadRequest:request];
    });
});

And in cellForItemAtIndexPath of CollectionView

for (UIView *subview in reusableAdCell.contentView.subviews) {
  [subview removeFromSuperview];
}

GADBannerView *adView = _tableViewItems[indexPath.row];
[reusableAdCell.contentView addSubview:adView];
adView.center = reusableAdCell.contentView.center;

return reusableAdCell;

Can someone help me for this issue?

0

There are 0 best solutions below