代码之家  ›  专栏  ›  技术社区  ›  Mc.Lover

IAD横幅背景图像

  •  0
  • Mc.Lover  · 技术社区  · 14 年前

    我想知道如何更改IAD黑色背景图像?

    alt text

    2 回复  |  直到 13 年前
        1
  •  2
  •   Brad Larson    14 年前

    你不能在一个标准的iPhone应用程序中运行模拟器。这只是一个测试广告,苹果提供给你的应用程序。

    如果您希望尝试正在构建的其他IAD设计,则需要从iOS开发中心获取IAD JS框架。这将在模拟器中安装一个IAD测试程序,允许您测试IAD构建。

        2
  •  0
  •   Bill the Lizard    13 年前

    我将这个任务分为三个简单的步骤。

    步骤1:

    1. 将IAD框架导入应用程序。

    2. 提供 #import <iAd/iAd.h> 在特定的控制器中显示广告。

    3. 提供其代表 UIViewController <ADBannerViewDelegate>

    4. 为该特定的视图控制器提供一个视图。假设我已经

    @property (weak, nonatomic) IBOutlet UIView *contentView;

    第2步:

    //Allocate it in ViewDidLoad method
    
    
    - (void)viewDidLoad
    
    {
    
    _bannerView = [[ADBannerView alloc] init];
    
    _bannerView.delegate = self;
    
    [super viewDidLoad];
    
    [self.view addSubview:_bannerView];
    
    }
    

    第3步:

    提供我在下面提到的它的委托方法。

    - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
    {
    if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
    _bannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
    } else {
    _bannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;
    }
    [self layoutAnimated:duration > 0.0];
    }
    
    - (void)bannerViewDidLoadAd:(ADBannerView *)banner
    {
    [self layoutAnimated:YES];
    }
    
    - (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
    {
    [self layoutAnimated:YES];
    }
    
    - (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
    {
    
    return YES;
    }
    
    - (void)bannerViewActionDidFinish:(ADBannerView *)banner
    {
    
    }
    - (void)layoutAnimated:(BOOL)animated
    {
    if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) {
    _bannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
    } else {
    _bannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;
    }
    
    CGRect contentFrame = self.view.bounds;
    CGRect bannerFrame = _bannerView.frame;
    if (_bannerView.bannerLoaded) {
    contentFrame.size.height -= _bannerView.frame.size.height;
    bannerFrame.origin.y = contentFrame.size.height;
    } else {
    bannerFrame.origin.y = contentFrame.size.height;
    }
    
    [UIView animateWithDuration:animated ? 0.25 : 0.0 animations:^{
    self.contentView.frame = contentFrame;
    [self.contentView layoutIfNeeded];
    _bannerView.frame = bannerFrame;
    }];
    }