From fc936c49ef3c2734173442042b7d5038aeaef301 Mon Sep 17 00:00:00 2001 From: Ibad9 <44775654+Ibad9@users.noreply.github.com> Date: Mon, 9 Mar 2026 17:40:31 +0500 Subject: [PATCH] fix(ios): IMA ad container resizing on orientation change (#4771) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 Co-authored-by: Kamil MoskaƂa <91079590+moskalakamil@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- ios/Video/Features/RCTIMAAdsManager.swift | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ios/Video/Features/RCTIMAAdsManager.swift b/ios/Video/Features/RCTIMAAdsManager.swift index 15d9511c..d36fb5cb 100644 --- a/ios/Video/Features/RCTIMAAdsManager.swift +++ b/ios/Video/Features/RCTIMAAdsManager.swift @@ -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())