iAd Banner白色继续展示

时间:2014-01-27 17:08:27

标签: ios show-hide iad adbannerview

在我的应用中添加iAd横幅,但当横幅为空(白色)横幅未隐藏时,我会尝试两种类型的代码:

.h

    #import <iAd/iAd.h>

    @interface HomeViewController : UIViewController <ADBannerViewDelegate> {

        ADBannerView *homeBanner;
    }

    //----------------------------------iAd BANNER-------------------------//
    @property (nonatomic, assign) BOOL bannerIsVisible;
    @property (nonatomic, strong) IBOutlet ADBannerView *homeBanner;
    @end
课程.m

上的

@synthesize homeBanner, bannerIsVisible;

//------------iAd Banner---------------------------------------//
- (void)bannerViewDidload:(ADBannerView *)abanner {

    if (!self.bannerIsVisible){

        [UIView beginAnimations:@"animationAdBannerOn" context:NULL];
        homeBanner.frame = CGRectOffset(homeBanner.frame, 0.0, 50.0);
        [UIView commitAnimations];
        self.bannerIsVisible = YES;
    } 
}
- (void)bannerView:(ADBannerView *)aBanner {

    if (!self.bannerIsVisible){

        [UIView beginAnimations:@"animationAdBannerOff" context:NULL];
        homeBanner.frame = CGRectOffset(homeBanner.frame, 0.0, -320.0);
        [UIView commitAnimations];
        self.bannerIsVisible = NO;
    }
}

如果横幅为白色,请使用此代码继续显示。

尝试第二个代码:

.h

    #import <iAd/iAd.h>

    @interface HomeViewController : UIViewController <ADBannerViewDelegate> {

        ADBannerView *homeBanner;
    }

    //----------------------------------iAd BANNER-------------------------//
    @property (nonatomic, strong) IBOutlet ADBannerView *homeBanner;
    @end

.m

- (void)viewDidLoad {

    [super viewDidLoad];
    [homeBanner setHidden:YES];
}

- (void)bannerViewDidload:(ADBannerView *)banner {

        [homeBanner setHidden:NO];
        NSLog(@"Showing");

}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {

    [homeBanner setHidden:YES];
    NSLog(@"Hidden");
}

并最终遇到同样的问题。

有什么想法吗?

感谢。

1 个答案:

答案 0 :(得分:0)

您是否为bannerView设置了委托?

在viewDidLoad中尝试这个 -

[homeBanner setDelegate:self];