fix(ios): IMA ad container resizing on orientation change (#4771)

* Fix IMA ad container not resizing on orientation change (iOS)

* refactor: lint

* chore: change comment text

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* refactor: remove redundant frame initialization

---------

Co-authored-by: Ibad Ahmed <ibadahmed@Ibads-MacBook-Pro.local>
Co-authored-by: Kamil Moskała <91079590+moskalakamil@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Ibad9
2026-03-09 17:40:31 +05:00
committed by GitHub
parent 9c981f6f72
commit fc936c49ef

View File

@@ -49,10 +49,19 @@
func requestAds() {
guard let _video else { return }
// fixes RCTVideo --> RCTIMAAdsManager --> IMAAdsLoader --> IMAAdDisplayContainer --> RCTVideo memory leak.
let adContainerView = UIView(frame: _video.bounds)
let adContainerView = UIView()
adContainerView.backgroundColor = .clear
_video.addSubview(adContainerView)
// Enable Auto Layout to ensure the ad container resizes with the video view.
adContainerView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
adContainerView.topAnchor.constraint(equalTo: _video.topAnchor),
adContainerView.bottomAnchor.constraint(equalTo: _video.bottomAnchor),
adContainerView.leadingAnchor.constraint(equalTo: _video.leadingAnchor),
adContainerView.trailingAnchor.constraint(equalTo: _video.trailingAnchor),
])
// Create ad display container for ad rendering.
let adDisplayContainer = IMAAdDisplayContainer(adContainer: adContainerView, viewController: _video.reactViewController())