0

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

替代文字

4

2 回答 2

2

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

如果您想尝试您正在构建的其他 iAd 设计,您需要从 iOS 开发中心获取 iAd JS 框架。这将在模拟器中安装 iAd Tester 应用程序,允许您测试 iAd 构建。

于 2010-10-26T14:18:24.403 回答
0

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

第1步:

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

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

  3. 提供其委托UIViewController <ADBannerViewDelegate>

  4. 为该特定 ViewController 提供一个视图。假设我已经采取

@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;
}];
}
于 2012-01-02T11:14:44.140 回答