larsacus / LARSAdController

Lightweight ad mediation for iOS to properly manage multiple ad networks dynamically including iAd and Google ads.
http://theonlylars.com/blog/2013/01/10/stupid-easy-ads-with-larsadcontroller-3-dot-0/
MIT License
269 stars 60 forks source link

containerView.hidden == YES after ad controller switch #97

Open dan55304 opened 10 years ago

dan55304 commented 10 years ago

I'm having an issue when primary ad controller can't get an ad and the secondary controller gets an ad. It appears animateBannerForAdapterVisible executes before animateBannerForAdapterHidden. The result is that ads are permanently hidden after the first ad controller switch.

In my case the primary controller is for iAd and the second for Google if that makes a difference.

There is no difference in behavior if the first ad is iAd or Google. The adapter is set to hidden every time after the first ad switch.

Can someone point me in the right direction? I've run out of things to try.

dan55304 commented 10 years ago

Here's a UIView dump:

LARSAdContainer:<LARSAdContainer: 0x10d575990; frame = (0 469; 320 50); hidden = YES; autoresize = W+TM; layer = <CALayer: 0x10d573990>>
| LARSAdContainer:<LARSAdContainer: 0x10d5762c0; frame = (0 0; 320 50); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x10d585f10>>
| | ADBannerView:<ADBannerView: 0x10cf4ce00; frame = (0 50; 320 50); clipsToBounds = YES; autoresize = LM+RM+TM; gestureRecognizers = <NSArray: 0x111716bb0>; layer = <CALayer: 0x10cf2fba0>>
| | | ADRemoteView:<ADRemoteView: 0x10d632b40; frame = (0 0; 320 50); autoresize = W+H; userInteractionEnabled = NO; layer = <CALayerHost: 0x10d63b6b0>>
| | | UIView:<UIView: 0x10d63c780; frame = (0 0; 320 50); alpha = 0; autoresize = W+H; userInteractionEnabled = NO; layer = <CALayer: 0x10d6455a0>>
| | GADBannerView:<GADBannerView: 0x10d711390; frame = (0 0; 320 50); clipsToBounds = YES; autoresize = LM+RM+TM; layer = <CALayer: 0x10d7026f0>>
| | | GADWebView:<GADWebView: 0x10d5197f0; baseClass = UIWebView; frame = (0 0; 320 50); clipsToBounds = YES; opaque = NO; autoresize = W+H; gestureRecognizers = <NSArray: 0x11462d460>; layer = <CALayer: 0x1143bc350>>
| | | | _UIWebViewScrollView:<_UIWebViewScrollView: 0x114625f60; frame = (0 0; 320 50); clipsToBounds = YES; autoresize = H; gestureRecognizers = <NSArray: 0x114625ef0>; layer = <CALayer: 0x10d582140>; contentOffset: {0, 0}>
| | | | | UIWebBrowserView:<UIWebBrowserView: 0x10f018c00; frame = (0 0; 320 50); opaque = NO; gestureRecognizers = <NSArray: 0x10d518ca0>; layer = <UIWebLayer: 0x10d540620>>
| | | | | UIImageView:<UIImageView: 0x1117b5ca0; frame = (0 46.5; 320 3.5); alpha = 0; opaque = NO; autoresize = TM; userInteractionEnabled = NO; layer = <CALayer: 0x1117b5e30>>
| | | | | UIImageView:<UIImageView: 0x1117b5f80; frame = (316.5 0; 3.5 50); alpha = 0; opaque = NO; autoresize = LM; userInteractionEnabled = NO; layer = <CALayer: 0x1117b6110>>
larsacus commented 10 years ago

Is it that you have no ads show up at all, or you have one ad adapter's hidden property set to YES?

dan55304 commented 10 years ago

The hidden property is set to YES. The ad displays briefly and then disappears leaving just a gray background where the ad should be. Tracing through the execution, the new ad is displayed (setting hidden to NO) and then the prior ad is animated out (setting hidden to YES). For now, I've changed animateBannerForAdapterHidden from:

self.containerView.hidden = YES;

to:

self.containerView.hidden = !anyAdsVisible;
dan55304 commented 10 years ago

BTW, even with my change, the ads disappear if the device is rotated. I have my app set to not allow rotation but LARS still responds to rotation attempts and my ads disappear leaving the gray rect where they should be.