Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fluid ads aren't restricted by parent width #123

Open
MicahDavid opened this issue Apr 20, 2024 · 5 comments
Open

Fluid ads aren't restricted by parent width #123

MicahDavid opened this issue Apr 20, 2024 · 5 comments

Comments

@MicahDavid
Copy link

The FLUID ads always go to the screen width, and are not restricted by the parent container width. Has anyone found a solution to this problem?

@chriszs
Copy link

chriszs commented May 10, 2024

I might be having the same problem, but seemingly only on iOS. Here's a banner ad which has a parent view with a margin applied:

Screenshot 2024-05-10 at 4 37 30 PM

Android (on the right) has the correct behavior of loading an ad that takes into account the parent view's margin. iOS (on the left) appears to be loading one based on the full width of the screen.

@chriszs
Copy link

chriszs commented May 10, 2024

Adding the following to ios/RNAdManagerBannerView.m seems to fix it:

- (void)layoutSubviews {
    [super layoutSubviews];

    if (GADAdSizeIsFluid(_bannerView.adSize)) {
        _bannerView.frame = self.bounds;
    }
}

@chriszs
Copy link

chriszs commented May 10, 2024

Looks like the native ad view code already has something like this:

-(void)layoutSubviews
{
[super layoutSubviews];
self.nativeAdView.frame = self.bounds;
self.bannerView.frame = self.bounds;
}

So it should be easy enough to patch the banner ad view with it. I'll try to offer a PR with that, though the fastest method might be switch to the native ad view instead, since I believe it also supports banners?

@chriszs
Copy link

chriszs commented May 12, 2024

The native view doesn't conform to its parent, either, but not because the banner view doesn't, but because the view above that doesn't.

@MicahDavid
Copy link
Author

Instead of using the banner with size fluid, I am using the nativeAdManager, and that has solved all of my problems. Hope this helps someone else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants