0

据我了解,iAd 是用 html5、js 和 css3 制作的——因此我假设驱动它的代码已下载到设备上进行显示。如果我的 ipad 与我的笔记本电脑在同一个无线网络上,我将如何将它下载到我的笔记本电脑以查看它是如何工作的?

4

2 回答 2

1

您是否尝试在将您的应用部署到应用商店之前进行 iAD 测试?您的 iAd 与您的 Apple Developer 帐户相关联,因此在将应用程序上传到商店之前只需要您的代码签名。回答您的问题,如果您想测试 iAds 是否适用于通用广告,以下是有关如何执行此操作的代码:

在视图控制器的 .h 文件中

#import "iAd/ADBannerView.h" //Add the iAd.framework to your Build

    @interface YourViewController: UIViewController <ADBannerViewDelegate> { 
//Dont forget to add the delegate

BOOL bannerDisplayed;

}

然后在你的 .m 文件中

 - (void) viewDidLoad {
   ADBannerView *adBanner = [[ADBannerView alloc] initWithFrame:CGRectMake(0, -50, 320, 50)]; 
    adBanner.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
    adBanner.delegate = self;
    [self.view addSubview:adBanner];
}

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

    if(!bannerDisplayed) {
        NSLog(@"iAd Banner Appear");
        [UIView beginAnimations:@"bannerAppear" context:NULL];
        banner.frame = CGRectOffset(banner.frame, 0, 411);
        [UIView commitAnimations];
        bannerDisplayed = YES;
    } else {
        NSLog(@"iAd Banner Appear Error. Not a FailAdWithError.");
    }
}

- (void) bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
    if(bannerDisplayed) {
        NSLog(@"Banner Error. Remove Ad from Screen");
        [UIView beginAnimations:@"bannerDisappear" context:NULL];

        banner.frame = CGRectOffset(banner.frame, 0, -411);
        [UIView commitAnimations];

        bannerDisplayed = NO;
    }
}

Apple 要求 iAd 能够自行移除/隐藏,以防您的 iAd 实例未检索到广告时发生错误。因此,可能需要一两秒钟才能出现,然后将其移除以模仿成功或失败。

于 2012-08-03T22:40:13.180 回答
0

我不确定您是否或如何下载 iAd,但您应该查看 iAd Producer https://developer.apple.com/iad/iadproducer/,它为您提供了足够的示例来了解它是如何工作的。

于 2012-08-03T16:55:02.313 回答