0

I am new to Adwhirl and am having some problems. I am setting my mainScreen controller as the delegate for AdView. While I am in this view, the ads refresh just fine. When I switch to another view though, the delegate no longer received any new ads(the delegates selectors are not fired). Is there a reason for this? I want one adView for my whole app, so I am passing a pointer around to it everywhere and adding it as a subview to the proper view.

Here is some code:

#pragma mark AdWhirl required delegate methods
- (NSString *)adWhirlApplicationKey {
    return MY_AD_WHIRL_APPLICATION_KEY;
}

- (UIViewController *)viewControllerForPresentingModalView {
    return self;
}

- (void)adWhirlDidReceiveAd:(AdWhirlView *)adWhirlView {
    adView.hidden = NO;
    if (self.view.window) {
    [UIView beginAnimations:@"AdWhirlDelegate.adWhirlDidReceiveAd:"
                    context:nil];
    [UIView setAnimationDuration:0.7];
    CGSize adSize = [adView actualAdSize];
    CGRect newFrame = adView.frame;
    newFrame.size = adSize;
    newFrame.origin.x = (self.view.bounds.size.width - adSize.width)/ 2;
    newFrame.origin.y = self.view.bounds.size.height - 50;
    adView.frame = newFrame;
    [UIView commitAnimations];
    }else {
        [UIView beginAnimations:@"AdWhirlDelegate.adWhirlDidReceiveAd:"
                        context:nil];
        [UIView setAnimationDuration:0.7];
        CGSize adSize = [adView actualAdSize];
        CGRect newFrame = adView.frame;
        newFrame.size = adSize;
        newFrame.origin.x = (self.view.bounds.size.width - adSize.width)/ 2;
        //newFrame.origin.y = self.view.bounds.size.height - 50;
        adView.frame = newFrame;
        [UIView commitAnimations];
    }
}
-(void)adWhirlDidFailToReceiveAd:(AdWhirlView *)adWhirlView usingBackup:(BOOL)yesOrNo
{
    adView.hidden = YES;
}

Note: The mainScreen controller is the one my app starts with..so it is always resident in memory. This is responsible for pushing the other views on screen. Am I missing something to get this working?

kamran619
  • 531
  • 10
  • 32
  • Are you sure that the delegate methods are not called? Where did you log them? self.view.window will be null if the controllers view is not on screen. – rdelmar Jul 15 '13 at 00:48
  • I have a breakpoint there whenever each one fires. They are only called when I am in mainscreen controller. When I segue to another view controller they stop being called, and the same ad is shown over and over again. – kamran619 Jul 15 '13 at 00:51

0 Answers0