{"action":"opened","issue":{"url":"https://api.github.com/repos/larsacus/LARSAdController/issues/121","labels_url":"https://api.github.com/repos/larsacus/LARSAdController/issues/121/labels{/name}","comments_url":"https://api.github.com/repos/larsacus/LARSAdController/issues/121/comments","events_url":"https://api.github.com/repos/larsacus/LARSAdController/issues/121/events","html_url":"https://github.com/larsacus/LARSAdController/issues/121","id":109002407,"number":121,"title":"Having trouble hiding AdBanner when no ad is visible","user":{"login":"robmontesinos","id":258556,"avatar_url":"https://avatars.githubusercontent.com/u/258556?v=3","gravatar_id":"","url":"https://api.github.com/users/robmontesinos","html_url":"https://github.com/robmontesinos","followers_url":"https://api.github.com/users/robmontesinos/followers","following_url":"https://api.github.com/users/robmontesinos/following{/other_user}","gists_url":"https://api.github.com/users/robmontesinos/gists{/gist_id}","starred_url":"https://api.github.com/users/robmontesinos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robmontesinos/subscriptions","organizations_url":"https://api.github.com/users/robmontesinos/orgs","repos_url":"https://api.github.com/users/robmontesinos/repos","events_url":"https://api.github.com/users/robmontesinos/events{/privacy}","received_events_url":"https://api.github.com/users/robmontesinos/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-30T02:27:32Z","updated_at":"2015-09-30T02:27:32Z","closed_at":null,"body":"Hi there, thank you for your tremendous work with this controller.\r\n\r\nI am having trouble hiding the banner and banner shadow when the ad is empty. I have several view controllers showing ads so I am using sub-classing to handle 'observeValueForKeyPath' and 'adController:(LARSAdController *)adController bannerChangedVisibility:(BOOL)anyBannerVisible'\r\n\r\nThe delegate method does not seem to be working reliably since I have several view controllers on the navigation controller stack, so I am relying on KVO in the super classes. A typical set up between super class and subclass looks as follows:\r\n\r\n```ObjectiveC\r\n- (void)adController:(LARSAdController *)adController bannerChangedVisibility:(BOOL)anyBannerVisible {\r\n    NSLog(@\"Changing visibility: %@ on %@\", anyBannerVisible ? @\"visible\" : @\"hidden\", NSStringFromClass([self class]));\r\n    if (anyBannerVisible && [self shouldDisplayAds] && !self.ignoreAds)\r\n        [self showAdBanner];\r\n    else\r\n        [self hideAdBanner];        \r\n}\r\n\r\n- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {\r\n    if ([keyPath isEqualToString:kLARSAdObserverKeyPathIsAdVisible]) {\r\n        NSLog(@\"Observing keypath \\\"%@\\\" on %@\", keyPath, NSStringFromClass([self class]));\r\n\r\n        BOOL anyAdsVisible = [change[NSKeyValueChangeNewKey] boolValue];\r\n        \r\n        // get a reference to the banner that is currently visible\r\n        UIView *bannerView = nil;\r\n        NSArray *instances = [[[LARSAdController sharedManager] adapterInstances] allValues];\r\n        for (id <TOLAdAdapter> adapterInstance in instances) {\r\n            bannerView = adapterInstance.bannerView;\r\n        }\r\n        \r\n        if (!self.ignoreAds) {\r\n            if (anyAdsVisible && [self shouldDisplayAds]) {\r\n                NSLog(@\"--->AD IS VISIBLE!!\");\r\n                [self showAdBanner];\r\n            } else {\r\n                NSLog(@\"--->AD IS NOT VISIBLE!!\");\r\n                [self hideAdBanner];\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n- (void)hideAdBanner {\r\n    NSLog(@\">>> Entering %s <<<\", __PRETTY_FUNCTION__);\r\n    [LARSAdController sharedManager].containerView.hidden = ![LARSAdController sharedManager].isAdVisible;\r\n}\r\n\r\n- (void)showAdBanner {\r\n    NSLog(@\">>> Entering %s <<<\", __PRETTY_FUNCTION__);\r\n    [LARSAdController sharedManager].containerView.hidden = ![LARSAdController sharedManager].isAdVisible;\r\n}\r\n\r\nsubclasses control the tableView layout constraints like so:\r\n\r\n```ObjectiveC\r\n- (void)showAdBanner {\r\n    [super showAdBanner];\r\n    NSLog(@\">>> Entering %s <<<\", __PRETTY_FUNCTION__);\r\n    [self animateTableViewBottomConstraint:kBannerHeight];\r\n}\r\n\r\n- (void)hideAdBanner {\r\n    [super hideAdBanner];\r\n    NSLog(@\">>> Entering %s <<<\", __PRETTY_FUNCTION__);\r\n    [self animateTableViewBottomConstraint:0.0];\r\n}\r\n\r\n- (void)animateTableViewBottomConstraint:(CGFloat)newConstant {\r\n    NSLog(@\">>> Entering %s <<<\", __PRETTY_FUNCTION__);\r\n    [self.view layoutIfNeeded];\r\n    \r\n    __weak typeof(self)weakSelf = self;\r\n    [UIView animateWithDuration:0.25\r\n                     animations:^{\r\n                         weakSelf.tableViewBottomConstraint.constant = newConstant;\r\n                         [weakSelf.view layoutIfNeeded];\r\n                     }\r\n     ];\r\n}\r\n\r\nWould you mind suggesting a way that I could control the adBanner appearance more reliably? Thank you in advance."}}