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:
@@ -49,10 +49,19 @@
|
|||||||
func requestAds() {
|
func requestAds() {
|
||||||
guard let _video else { return }
|
guard let _video else { return }
|
||||||
// fixes RCTVideo --> RCTIMAAdsManager --> IMAAdsLoader --> IMAAdDisplayContainer --> RCTVideo memory leak.
|
// fixes RCTVideo --> RCTIMAAdsManager --> IMAAdsLoader --> IMAAdDisplayContainer --> RCTVideo memory leak.
|
||||||
let adContainerView = UIView(frame: _video.bounds)
|
let adContainerView = UIView()
|
||||||
adContainerView.backgroundColor = .clear
|
adContainerView.backgroundColor = .clear
|
||||||
_video.addSubview(adContainerView)
|
_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.
|
// Create ad display container for ad rendering.
|
||||||
let adDisplayContainer = IMAAdDisplayContainer(adContainer: adContainerView, viewController: _video.reactViewController())
|
let adDisplayContainer = IMAAdDisplayContainer(adContainer: adContainerView, viewController: _video.reactViewController())
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user