Skip to content

Commit 77681cc

Browse files
author
Thibaud Saint-Etienne
committed
fix admob resize issue
1 parent 0cc3cf0 commit 77681cc

File tree

5 files changed

+14
-16
lines changed

5 files changed

+14
-16
lines changed

TeadsSampleApp/Base.lproj/Main.storyboard

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@
4242
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="80u-jD-Bwf">
4343
<rect key="frame" x="8" y="46" width="359" height="58.5"/>
4444
<subviews>
45-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Scroll down to see your creative" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumFontSize="16" preferredMaxLayoutWidth="359" translatesAutoresizingMaskIntoConstraints="NO" id="TF7-Xl-dJO">
45+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Scroll down to see your creative" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumFontSize="16" preferredMaxLayoutWidth="359" translatesAutoresizingMaskIntoConstraints="NO" id="TF7-Xl-dJO">
4646
<rect key="frame" x="0.0" y="34.5" width="359" height="24"/>
4747
<fontDescription key="fontDescription" type="system" weight="thin" pointSize="20"/>
4848
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
4949
<nil key="highlightedColor"/>
5050
</label>
51-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="InRead Direct TableView Integration" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumFontSize="16" preferredMaxLayoutWidth="359" translatesAutoresizingMaskIntoConstraints="NO" id="23G-ts-bP1">
51+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="InRead Direct TableView Integration" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumFontSize="16" preferredMaxLayoutWidth="359" translatesAutoresizingMaskIntoConstraints="NO" id="23G-ts-bP1">
5252
<rect key="frame" x="0.0" y="0.0" width="359" height="26.5"/>
5353
<fontDescription key="fontDescription" type="system" pointSize="22"/>
5454
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
@@ -1110,13 +1110,13 @@
11101110
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="tKl-dF-Skq">
11111111
<rect key="frame" x="8" y="46" width="359" height="58.5"/>
11121112
<subviews>
1113-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Scroll down to see your creative" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumFontSize="16" preferredMaxLayoutWidth="359" translatesAutoresizingMaskIntoConstraints="NO" id="luA-K5-FUi">
1113+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Scroll down to see your creative" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumFontSize="16" preferredMaxLayoutWidth="359" translatesAutoresizingMaskIntoConstraints="NO" id="luA-K5-FUi">
11141114
<rect key="frame" x="0.0" y="34.5" width="359" height="24"/>
11151115
<fontDescription key="fontDescription" type="system" weight="thin" pointSize="20"/>
11161116
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
11171117
<nil key="highlightedColor"/>
11181118
</label>
1119-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="InRead Admob TableView Integration" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumFontSize="16" preferredMaxLayoutWidth="359" translatesAutoresizingMaskIntoConstraints="NO" id="kOh-ef-m1R">
1119+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="InRead Admob TableView Integration" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumFontSize="16" preferredMaxLayoutWidth="359" translatesAutoresizingMaskIntoConstraints="NO" id="kOh-ef-m1R">
11201120
<rect key="frame" x="0.0" y="0.0" width="359" height="26.5"/>
11211121
<fontDescription key="fontDescription" type="system" pointSize="22"/>
11221122
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
@@ -1287,13 +1287,13 @@
12871287
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="MHN-Zg-bXP">
12881288
<rect key="frame" x="8" y="46" width="359" height="58.5"/>
12891289
<subviews>
1290-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Scroll down to see your creative" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumFontSize="16" preferredMaxLayoutWidth="359" translatesAutoresizingMaskIntoConstraints="NO" id="57g-ag-daH">
1290+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Scroll down to see your creative" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumFontSize="16" preferredMaxLayoutWidth="359" translatesAutoresizingMaskIntoConstraints="NO" id="57g-ag-daH">
12911291
<rect key="frame" x="0.0" y="34.5" width="359" height="24"/>
12921292
<fontDescription key="fontDescription" type="system" weight="thin" pointSize="20"/>
12931293
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
12941294
<nil key="highlightedColor"/>
12951295
</label>
1296-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="InRead Mopub TableView Integration" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumFontSize="16" preferredMaxLayoutWidth="359" translatesAutoresizingMaskIntoConstraints="NO" id="17h-YO-SmB">
1296+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="InRead Mopub TableView Integration" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumFontSize="16" preferredMaxLayoutWidth="359" translatesAutoresizingMaskIntoConstraints="NO" id="17h-YO-SmB">
12971297
<rect key="frame" x="0.0" y="0.0" width="359" height="26.5"/>
12981298
<fontDescription key="fontDescription" type="system" pointSize="22"/>
12991299
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
@@ -1623,13 +1623,13 @@
16231623
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dJm-OU-v2c">
16241624
<rect key="frame" x="8" y="46" width="359" height="58.5"/>
16251625
<subviews>
1626-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Scroll down to see your creative" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumFontSize="16" preferredMaxLayoutWidth="359" translatesAutoresizingMaskIntoConstraints="NO" id="Uw2-7T-qdp">
1626+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Scroll down to see your creative" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumFontSize="16" preferredMaxLayoutWidth="359" translatesAutoresizingMaskIntoConstraints="NO" id="Uw2-7T-qdp">
16271627
<rect key="frame" x="0.0" y="34.5" width="359" height="24"/>
16281628
<fontDescription key="fontDescription" type="system" weight="thin" pointSize="20"/>
16291629
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
16301630
<nil key="highlightedColor"/>
16311631
</label>
1632-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="InRead Direct TableView Integration" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumFontSize="16" preferredMaxLayoutWidth="359" translatesAutoresizingMaskIntoConstraints="NO" id="vO8-XK-5gn">
1632+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="InRead Direct TableView Integration" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumFontSize="16" preferredMaxLayoutWidth="359" translatesAutoresizingMaskIntoConstraints="NO" id="vO8-XK-5gn">
16331633
<rect key="frame" x="0.0" y="0.0" width="359" height="26.5"/>
16341634
<fontDescription key="fontDescription" type="system" pointSize="22"/>
16351635
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>

TeadsSampleApp/Controllers/InRead/Admob/ScrollView/InReadAdmobScrollViewController.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,16 @@ class InReadAdmobScrollViewController: TeadsViewController {
5656
}
5757

5858
private func resizeAd(height: CGFloat) {
59-
bannerView.resize(GADAdSizeFromCGSize(CGSize(width: slotView.frame.width, height: height)))
6059
slotViewHeightConstraint.constant = height
60+
bannerView.resize(GADAdSizeFromCGSize(CGSize(width: slotView.frame.width, height: height)))
6161
}
6262

6363
}
6464

6565
extension InReadAdmobScrollViewController: GADBannerViewDelegate {
6666

6767
func bannerViewDidReceiveAd(_ bannerView: GADBannerView) {
68-
// reset the size to "kGADAdSizeMediumRectangle" if a didFailToReceiveAdWithError was triggered before.
69-
resizeAd(height: bannerView.adSize.size.height)
68+
// not used
7069
}
7170

7271
/// Tells the delegate an ad request failed.

TeadsSampleApp/Controllers/InRead/Admob/TableView/InReadAdmobTableViewController.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,7 @@ extension InReadAdmobTableViewController: GADBannerViewDelegate {
143143

144144
/// Tells the delegate an ad request loaded an ad.
145145
func bannerViewDidReceiveAd(_ bannerView: GADBannerView) {
146-
// reset the size to "kGADAdSizeMediumRectangle" if a didFailToReceiveAdWithError was triggered before.
147-
resizeAd(height: bannerView.adSize.size.height)
146+
// not used
148147
}
149148

150149
/// Tells the delegate an ad request failed.

TeadsSampleApp/Controllers/InRead/Direct/ScrollView/InReadDirectScrollViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ class InReadDirectScrollViewController: TeadsViewController {
4242
}
4343

4444
func resizeTeadsAd(adRatio: TeadsAdRatio) {
45-
teadsAdHeightConstraint.constant = adRatio.calculateHeight(for: view.frame.width)
45+
self.adRatio = adRatio
46+
teadsAdHeightConstraint.constant = adRatio.calculateHeight(for: teadsAdView.frame.width)
4647
}
4748

4849
func closeAd() {
@@ -70,7 +71,6 @@ extension InReadDirectScrollViewController: TeadsInReadAdPlacementDelegate {
7071

7172
func didUpdateRatio(ad: TeadsInReadAd, adRatio: TeadsAdRatio) {
7273
resizeTeadsAd(adRatio: adRatio)
73-
self.adRatio = adRatio
7474
}
7575

7676
}

TeadsSampleApp/Controllers/InRead/SAS/ScrollView/InReadSASScrollViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class InReadSASScrollViewController: TeadsViewController {
6161
extension InReadSASScrollViewController: TeadsMediatedAdViewDelegate {
6262

6363
func didUpdateRatio(_ adView: UIView, adRatio: TeadsAdRatio) {
64-
adViewHeightConstraint.constant = adRatio.calculateHeight(for: adView.bounds.width)
64+
adViewHeightConstraint.constant = adRatio.calculateHeight(for: slotView.bounds.width)
6565
}
6666

6767
}

0 commit comments

Comments
 (0)