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

Adding "iAD" on UITableView, the banner doesn't take in consideration content offset #89

Closed bsorrentino closed 10 years ago

bsorrentino commented 10 years ago

I've added "iAD" on UITableView where i had updated contentOffset. As consequence the banner was showed in wrong way because it doesn't take in consideration this case.

I've added the following code in LARSAdController.m method containerFrameForInterfaceOrientation and the problem has been fixed


    if( [self.parentView isKindOfClass:[UIScrollView class]] ) {

        yOrigin += ((UIScrollView *)self.parentView).contentOffset.y;

    }

Is it possible to add this fix ?

Thanks in advance

larsacus commented 10 years ago

As a general rule, you really should not be modifying view hierarchies which you do not directly control. Can you give me more description on what the exact issue is. Maybe post a screenshot?

bsorrentino commented 10 years ago

Since i've updated the contentOffset to hide searchBar at startup of my UITableViewController (see code below), when the "iAD' banner shows up, its Y coordinate is wrong (should be less, see screenshot). For that reasons i added the code above that fix this problem

self.tableView.contentOffset = CGPointMake(0, self.searchBar.frame.size.height);

screenshot_2

larsacus commented 10 years ago

I think i see what the issue is in this case. It looks like your view controller is going to have to listen for when the banner is visible and update the view hierarchy to accommodate for this change. You can listen via KVO for changes in the banner visibility property on LARSAdController by subscribing to updates via the constant kLARSAdObserverKeyPathIsAdVisible I have exposed. You can learn more about subscribing for KVO updates here. In your observer's callback, you will simply check to see if the banner is visible and adjust your table view accordingly. The ad controller should not modify the view hierarchy of the view that it is a child of.

bsorrentino commented 10 years ago

Thanks for feedback. (I prefer a out-of-box solution)

I'll try and let you know