Weird question, and I've been bannging my head against this wall for hours and haven't been able to solve it.
I have a iOS 7 only app that uses storyboards. On my main root view controller, I display an iAd banner at the bottom of the view using self.canDisplayBannerAds = YES. This works perfectly.
I have a settings view controller, and from there, my users can make an in app purchase to remove the ads permanently. That functionality works as well. I store a BOOL value in NSUserDefaults standardUserDefaults to track if they've made the purchase.
What is stumping me is that if a user is receiving ads in the banner, goes into the settings view controller, then to my purchase view controller, makes the purchase successfully, then returns to the main root view, the banner ad remains visible. If the user completely quits the app, then relaunches, it doesn't show up again, becuase this is how I display the banner in viewWillAppear:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
bool saved = [defaults boolForKey:t_Save];
if (saved == NO) {
self.canDisplayBannerAds = YES;
} else if (saved == YES) {
self.canDisplayBannerAds = NO;
}
NSLog(self.canDisplayBannerAds ? @"YES" : @"NO");
So, this logic works fine when they re-launch the app after they've made or restored the purchase. But, I want the view to update right after they make the purchase. However, I can't for the life of me get that stupid banner ad to disappear in the app when it was there when they first launched it.
What is weird if that if I create a button that just sets self.canDisplayBannerAds = NO, then that DOES make the banner ad disappear. But it doesn't work when called in viewWillAppear, viewDidAppear, or even in a dedicated method I created that get's called once the purchase is made.
I was thinking that maybe the banner view is setting in a cache somewhere and it just isn't getting nil'ed out, but I don't know how to force that. I was also thinking maybe if I could force the root view controller to basically go to nil and start over from scratch, that might do it, but I don't know how to force that either.
Anyone have any thoughts?
I had the same problem and found a workaround that worked for me:
I don't think this is a clean solution but since it is finaly working i will keep it in until i find a better solution.