fixed scaling issue of ad in webseries.

This commit is contained in:
2024-09-11 19:39:34 +05:30
parent 40193095a8
commit cc70306759
3 changed files with 22 additions and 19 deletions

View File

@@ -42,7 +42,7 @@ class GamesListVC: UIViewController {
Task {
do {
interstitial = try await GADInterstitialAd.load(
withAdUnitID: "ca-app-pub-3940256099942544/4411468910", request: GADRequest())
withAdUnitID: "ca-app-pub-5699008063638916/8126400123", request: GADRequest())
interstitial?.fullScreenContentDelegate = self
rewardedAd = try await GADRewardedAd.load(

View File

@@ -6,6 +6,7 @@
//
import UIKit
import GoogleMobileAds
protocol ReloadSeriesFavLike{
func updateRows(index : Int, type : FavCellCLick, isFav : Bool? , isLike : Bool?, id : Int?)
@@ -105,6 +106,26 @@ class WebSeriesVC: UIViewController {
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
vm.updateTableHeight()
var bannerView = GADBannerView()
let viewWidth = headerView.frame.inset(by: headerView.safeAreaInsets).width
// Here the current interface orientation is used. Use
// GADLandscapeAnchoredAdaptiveBannerAdSizeWithWidth or
// GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth if you prefer to load an ad of a
// particular orientation,
let adaptiveSize = GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth(viewWidth)
bannerView = GADBannerView(adSize: adaptiveSize)
bannerView.center = headerView.center
bannerView.frame = CGRect(x: 0, y: 0, width: headerView.frame.width, height: headerView.frame.height)
headerView.addSubview(bannerView)
bannerView.adUnitID = K.GoogleAdIDs.themeTwo
bannerView.rootViewController = self
bannerView.load(GADRequest())
bannerView.layoutIfNeeded()
}
// MARK: - Tap Handler

View File

@@ -7,7 +7,6 @@
import Foundation
import Alamofire
import GoogleMobileAds
class WebSeriesVM{
@@ -115,24 +114,7 @@ class WebSeriesVM{
}
}
}else{
var bannerView = GADBannerView()
let viewWidth = vc.headerView.frame.inset(by: vc.headerView.safeAreaInsets).width
// Here the current interface orientation is used. Use
// GADLandscapeAnchoredAdaptiveBannerAdSizeWithWidth or
// GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth if you prefer to load an ad of a
// particular orientation,
let adaptiveSize = GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth(viewWidth)
bannerView = GADBannerView(adSize: adaptiveSize)
bannerView.center = vc.headerView.center
bannerView.frame = CGRect(x: 0, y: 0, width: vc.headerView.frame.width, height: vc.headerView.frame.height)
vc.headerView.addSubview(bannerView)
bannerView.adUnitID = K.GoogleAdIDs.themeTwo
bannerView.rootViewController = self.vc
bannerView.load(GADRequest())
}
}