@@ -114,12 +114,6 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell
114
114
if ([indexPath isEqual: self .insertionPath]) {
115
115
self.adCell = [collectionView dequeueReusableCellWithReuseIdentifier: @" teadsAdCell" forIndexPath: indexPath];
116
116
117
- [self .adCell.contentView addSubview: self .teadsAd.videoView];
118
- if (!self.videoViewAdded ) {
119
- [self .teadsAd videoViewWasAdded ]; // Inform that Teads Ad was added
120
- self.videoViewAdded = YES ;
121
- }
122
-
123
117
return self.adCell ;
124
118
} else {
125
119
CustomCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier: collectionViewCellID forIndexPath: indexPath];
@@ -140,7 +134,9 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell
140
134
#pragma mark - UIScrollView
141
135
142
136
- (void )scrollViewDidScroll : (UIScrollView *)scrollView {
143
- [self .teadsAd videoViewDidMove: scrollView]; // Inform TeadsAd that the view did move in its scrollView container
137
+ if (self.videoViewAdded ) {
138
+ [self .teadsAd videoViewDidMove: scrollView]; // Inform TeadsAd that the view did move in its scrollView container
139
+ }
144
140
}
145
141
146
142
#pragma mark - UICollectionView delegate
@@ -153,6 +149,18 @@ - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollection
153
149
}
154
150
}
155
151
152
+
153
+ -(void )collectionView : (UICollectionView *)collectionView willDisplayCell : (UICollectionViewCell *)cell forItemAtIndexPath : (NSIndexPath *)indexPath {
154
+ if ([indexPath isEqual: self .insertionPath]) { // self.insertionPath is the indexPath where TeadsAd was added
155
+ if (!self.videoViewAdded ) {
156
+ [self .adCell.contentView addSubview: self .teadsAd.videoView];
157
+ [self .teadsAd videoViewWasAdded ]; // Inform that Teads Ad was added and cell will be displayed
158
+ self.videoViewAdded = YES ;
159
+ }
160
+ }
161
+ }
162
+
163
+
156
164
#pragma mark -
157
165
#pragma mark - Your methods to calculate Custom Ad size
158
166
0 commit comments