@@ -19,6 +19,7 @@ public class SyncWebViewTFACustomAdView: NSObject, WebViewHelperDelegate, TFAAdD
1919 var isLoaded = false
2020 var adViewConstraints = [ NSLayoutConstraint] ( )
2121 var adViewHeightConstraint : NSLayoutConstraint ?
22+ var adRatio : CGFloat = 16 / 9.0
2223
2324 public init ( webView: WKWebView , selector: String , adView: TFACustomAdView , adSettings: TeadsAdSettings ? = nil ) {
2425 self . webViewHelper = WebViewHelper ( webView: webView, selector: selector)
@@ -43,10 +44,8 @@ public class SyncWebViewTFACustomAdView: NSObject, WebViewHelperDelegate, TFAAdD
4344 }
4445
4546 @objc func rotationDetected( ) {
46- if let adView = self . adView {
47- //update the slot when the rotation occurs
48- self . webViewHelper. updateSlot ( adRatio: adView. creativeRatio)
49- }
47+ //update the slot when the rotation occurs
48+ self . webViewHelper. updateSlot ( adRatio: self . adRatio)
5049 }
5150
5251 // MARK: WebViewHelperDelegate
@@ -97,8 +96,9 @@ public class SyncWebViewTFACustomAdView: NSObject, WebViewHelperDelegate, TFAAdD
9796 // MARK: TeadsAdDelegate
9897
9998 public func didReceiveAd( _ ad: TFACustomAdView , adRatio: CGFloat ) {
99+ self . adRatio = adRatio
100100 //update slot with the right ratio
101- self . webViewHelper. updateSlot ( adRatio: adRatio)
101+ self . webViewHelper. updateSlot ( adRatio: self . adRatio)
102102 //open the slot
103103 self . webViewHelper. openSlot ( )
104104 }
@@ -129,6 +129,6 @@ public class SyncWebViewTFACustomAdView: NSObject, WebViewHelperDelegate, TFAAdD
129129
130130 public func adDidCloseFullscreen( _ ad: TFACustomAdView ) {
131131 //update the slot in case there was a rotation or a layout change to be sure that the ad has the right layout
132- self . webViewHelper. updateSlot ( adRatio: ad . adRatio)
132+ self . webViewHelper. updateSlot ( adRatio: self . adRatio)
133133 }
134134}
0 commit comments