0

我是 Adwhirl 的新手,遇到了一些问题。我将我的 mainScreen 控制器设置为 AdView 的代表。当我在这个视图中时,广告刷新得很好。但是,当我切换到另一个视图时,代表不再收到任何新广告(代表选择器不会被触发)。是否有一个原因?我想要一个用于我的整个应用程序的 adView,所以我到处传递一个指向它的指针,并将它作为子视图添加到正确的视图中。

这是一些代码:

#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;
}

注意: mainScreen 控制器是我的应用程序启动的控制器......所以它总是驻留在内存中。这负责在屏幕上推送其他视图。我错过了一些东西来让它工作吗?

4

0 回答 0