1

我开发了一个最近获得苹果批准的应用程序。但问题是 iAd 没有在 iphone 中显示,而 ipad iAd 显示完美。在开发时,iAd 已加载并在 iPhone 和 iPad 上进行测试广告。但是在获得苹果的批准后,我从商店下载了应用程序,注意到 iAd 没有加载到 iphone 中,但它正在加载到 ipad 中。我在其他应用程序中检查了 iphone 中的其他应用程序 iAd 工作正常,但在我的应用程序中 iAd 没有加载。那么我现在应该怎么做才能在 iphone 中加载 iAd。

我在应用程序中使用的代码是

-(void)showiAdInView
{
if (!appDelegate.isUpgraded) {
    bannerView = [[ADBannerView alloc] init];
    bannerView.delegate = self;
    bannerView.backgroundColor = [UIColor colorWithWhite:1.0f alpha:0.005f];
    bannerView.hidden = TRUE;
    bannerIsVisible = FALSE;
    [self.view addSubview:bannerView];
}
}
-(void)bannerViewDidLoadAd:(ADBannerView *)banner
{
bannerIsVisible = YES;
bannerView.hidden = FALSE;
NSLog(@"ADBanner is Showing");
[self bannerViewShow];
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
bannerIsVisible = FALSE;
bannerView.hidden = TRUE;
NSLog(@"ADBanner is Hidding");
NSLog(@"%@",[error description]);
[self bannerViewHide];
}

-(BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:  (BOOL)willLeave
{
if ([self.captureSession isRunning]) {
    [self.captureSession stopRunning];
    iAdLoaded = TRUE;
}
return YES;
}
-(void)bannerViewActionDidFinish:(ADBannerView *)banner
{
UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
[self willRotateToInterfaceOrientation:interfaceOrientation duration:0.2f];
if (![self.captureSession isRunning] && iAdLoaded) {
    [self.captureSession startRunning];
    iAdLoaded = FALSE;
}
}
-(void)bannerViewShow
{
[bannerView setBackgroundColor:[UIColor colorWithWhite:1.0f alpha:0.005f]];
UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) 
{
    if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDelegate:self];
        [UIView setAnimationDuration:0.5];
        [MsgtextView setFrame:MsgTextVwAdBannerFrame];
        [UIView commitAnimations];
        adBannerFrame = CGRectMake(0, 190, 320, 50);
        clearButton.frame = CGRectMake(ClearButtonFramePotrait.origin.x, ClearButtonFramePotrait.origin.y, ClearButtonFramePotrait.size.width, ClearButtonFramePotrait.size.height);
        [self.view bringSubviewToFront:bannerView];
        [bannerView setFrame:adBannerFrame];
        [bannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierPortrait];

    }
    else if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDelegate:self];
        [UIView setAnimationDuration:0.5];
        [MsgtextView setFrame:CGRectMake(MsgTextVwAdBannerFrame.origin.x, MsgTextVwAdBannerFrame.origin.y, MsgTextVwAdBannerFrame.size.width, MsgTextVwAdBannerFrame.size.height+8)];
        [UIView commitAnimations];
        adBannerFrame = CGRectMake(0, 105, 470, 32);
        clearButton.frame = CGRectMake(ClearButtonFrameLandscape.origin.x, ClearButtonFrameLandscape.origin.y, ClearButtonFrameLandscape.size.width, ClearButtonFrameLandscape.size.height);
        [bannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierLandscape];
        [self.view bringSubviewToFront:bannerView];
        [bannerView setFrame:adBannerFrame];

    }
}
else if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
    if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDelegate:self];
        [UIView setAnimationDuration:0.5];
        [MsgtextView setFrame:MsgTextVwAdBannerFrame];
        [UIView commitAnimations];
        adBannerFrame = CGRectMake(0, 640, 768, 50);
        [bannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierPortrait];
        clearButton.frame = CGRectMake(ClearButtonFrame_iPadPotrait.origin.x, ClearButtonFrame_iPadPotrait.origin.y, ClearButtonFrame_iPadPotrait.size.width, ClearButtonFrame_iPadPotrait.size.height);
        [self.view bringSubviewToFront:bannerView];
        [bannerView setFrame:adBannerFrame];
    }
    else if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDelegate:self];
        [UIView setAnimationDuration:0.5];
        [MsgtextView setFrame:CGRectMake(MsgTextVwAdBannerFrame.origin.x, MsgTextVwAdBannerFrame.origin.y, MsgTextVwAdBannerFrame.size.width, MsgTextVwAdBannerFrame.size.height+8)];
        [UIView commitAnimations];
        adBannerFrame = CGRectMake(0, 325, 1024, 32);
        [bannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierLandscape];
        clearButton.frame = CGRectMake(ClearButtonFrame_iPadPotrait.origin.x, ClearButtonFrame_iPadPotrait.origin.y, ClearButtonFrame_iPadPotrait.size.width, ClearButtonFrame_iPadPotrait.size.height);
        [self.view bringSubviewToFront:bannerView];
        [bannerView setFrame:adBannerFrame];
    }
}
}
-(void)bannerViewHide
{
[bannerView setBackgroundColor:[UIColor clearColor]];
UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) 
{
    if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDelegate:self];
        [UIView setAnimationDuration:0.5];
        [MsgtextView setFrame:MsgTextVwFrame];
        clearButton.frame = ClearButtonFramePotrait;
        [bannerView setHidden:YES];
        [UIView commitAnimations];
    }
    else if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDelegate:self];
        [UIView setAnimationDuration:0.5];
        [MsgtextView setFrame:MsgTextVwFrame];
        clearButton.frame = ClearButtonFrameLandscape;
        [bannerView setHidden:YES];
        [UIView commitAnimations];
    }
}
else if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
    if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDelegate:self];
        [UIView setAnimationDuration:0.5];
        [MsgtextView setFrame:MsgTextVwFrame];
        clearButton.frame = ClearButtonFrame_iPadPotrait;
        [bannerView setHidden:YES];
        [UIView commitAnimations];
    }
    else if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDelegate:self];
        [UIView setAnimationDuration:0.5];
        [MsgtextView setFrame:MsgTextVwFrame];
        clearButton.frame = ClearButtonFrame_iPadPotrait;
        [bannerView setHidden:YES];
        [UIView commitAnimations];
    }
}
}
4

1 回答 1

3

总体而言,iAd 的填充率非常低。广告网络(包括 iAd)向您发送的广告越多,您的点击率就越高;即,点击您应用中广告的用户:您在应用中展示的广告的比例。如果您确认测试广告有效并且您刚刚发布了该应用程序,那么 Apple 完全有可能只需要一点时间就可以向您发送有关 iPhone 版本的广告文件。给它几天,看看它是怎么回事。

或者,我注意到您的“isUpgraded”代码,有没有可能,在您正在测试的 iPhone 上,您购买了升级并忘记了,现在不再返回广告?

于 2012-05-19T02:14:02.853 回答