I've recently added Native Ads from AdMob in my iOS application. I've created a new cell and it has a view of type GADUnifiedNativeAdView. I've followed the instructions from Google and everything appears to be working great in the sense it fetches the ad, shows it, etc.
My problem is the width of the ad exceeds what I want each tableviewcell to be:
As you can see, the white goes beyond the teal and purple rectangles; I want the white rectangle (the ad) to be the same width).
I've tried with constraints, fixed width..Really everything, and despite that, the ad just "breaks out" and takes up the full width. I did some reading on StackOverflow and heard this might be by design, but wanted to see if anyone more experienced in this area can give me guidance here on setting a width.
Thanks in advance!
Their documentation states:
@interface GADUnifiedNativeAdView : UIView
Base class for native ad views. Your native ad view must be a subclass of this class and must call superclass methods for all overridden methods.
Try creating a subclass and then override layoutSubviews
method to set a frame for the subview you need.
I'm not sure (but with the help of Xcode's View Debugger you can try to find the exact subview), most likely white container view is a bodyView.
Please treat this answer as an idea of how to work around the behavior you experience.