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

First load correct receives orientation change, second does not #82

Closed TwentyThreeDegrees closed 9 years ago

TwentyThreeDegrees commented 10 years ago

When my app first loads a full screen iPad view the ad banner gets correctly loaded at the bottom of the view, I see two calls to viewDidLayoutSubviews, then LARS handles the orientation change and I get another call to viewDidLayoutSubviews:

LARSAdController [line 178]: View is landscape
LARSAdController [line 210]: Container frame: {{0, 494}, {1004, 90}}
LARSAdController [line 523]: Creating new instance of adapter class "TOLAdAdapteriAds"
LARSAdController [line 563]: Successfully created instance of "TOLAdAdapteriAds"
LARSAdController [line 474]: Initial banner frame <iAds>: {{118, 90}, {768, 66}}
LARSAdController [line 704]: Registering for orientation notifications
LARSAdController [line 178]: View is landscape
LARSAdController [line 210]: Container frame: {{0, 494}, {1004, 90}}
viewDidLayoutSubviews
viewDidLayoutSubviews
LARSAdController [line 733]: Handling orientation change
viewDidLayoutSubviews

This works well. When the view is removed and I make a new instance of the view however I get this:

LARSAdController [line 178]: View is landscape
LARSAdController [line 210]: Container frame: {{0, 494}, {1004, 90}}
LARSAdController [line 178]: View is landscape
LARSAdController [line 210]: Container frame: {{0, 494}, {1004, 90}}
LARSAdController [line 499]: Final banner frame <iAds>: {{118, 24}, {768, 66}}
viewDidLayoutSubviews
viewDidLayoutSubviews

There is no update to handle the orientation change, the Ad container appears in the middle of the view (and slightly off screen) - this only appears to happen in landscape view on my iPad though. I can see that the code to add the Ad container gets called (it's in viewDidLoad) both times.

larsacus commented 10 years ago

The only thing this library is doing is listening for system rotation notifications (UIDeviceOrientationDidChangeNotification). This is posted by iOS as a result of an orientation change, so I'm not sure why this is not being posted if you really are changing the orientation.

TwentyThreeDegrees commented 10 years ago

The orientation isn't changing, it's staying landscape the whole time when the problem occurs.

I've forced a bad fix by manually adjusting the ad frame for now which is working!

On 15 May 2014, at 18:34, Lars Anderson notifications@github.com wrote:

The only thing this library is doing is listening for system rotation notifications (UIDeviceOrientationDidChangeNotification). This is posted by iOS as a result of an orientation change, so I'm not sure why this is not being posted if you really are changing the orientation.

— Reply to this email directly or view it on GitHub.

paoloandrea commented 10 years ago

Please fix it ;)

larsacus commented 10 years ago

@paoloandrea instead of just telling me to fix it, could you perhaps provide some more information so that someone else can reproduce it?