简体   繁体   English

如何下载iAd的代码

[英]how to download code for an iAd

From my understanding, iAds are made with html5, js, and css3 - therefore i'm assuming that the code that drives it is downloaded onto the device to display. 据我了解,iAd是使用html5,js和css3制作的-因此,我假设驱动它的代码已下载到设备上进行显示。 How would i go about downloading it to my laptop to see how it works, if my ipad is on the same wireless network as my laptop? 如果我的iPad与笔记本电脑位于同一无线网络上,我该如何将其下载到笔记本电脑上以查看其工作原理?

Are you trying to do iAD testing before deploying your app on the app store? 您是否正在尝试在应用商店上部署应用之前进行iAD测试? Your iAds tie in with your Apple Developer account and therefore would only require your Code Signing before uploading the app to the store. 您的iAd与您的Apple Developer帐户相关联,因此仅需进行代码签名即可将应用程序上载到商店。 Answering your question, if you would like to test if iAds works with a generic Ad, heres the code on how to go about doin that: 回答您的问题,如果您想测试iAds是否可以与通用广告一起使用,请在此找到有关如何执行此操作的代码:

In your .h File of the view controller 在视图控制器的.h文件中

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

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

BOOL bannerDisplayed;

}

Then in your .m file 然后在您的.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 requires that the iAd be able to remove/hide itself incase an error occurs when your iAd instance does not retrieve the Ad. Apple要求iAd能够删除/隐藏自身,以防iAd实例未检索到广告时发生错误。 Therefore it might take a second or two to show up then remove itself so as to mimic a success or failure. 因此,可能要花一两秒钟才能出现,然后将其删除以模仿成功或失败。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM