问题描述
当我运行我的应用程序时,我收到了iAd横幅视图的此消息。这是什么意思?
When I run my application I get this message for iAd banner view. What does it mean?
这是我的代码:
#pragma mark -
#pragma mark create BannerView:
- (void)createAdBannerView {
Class classAdBannerView = NSClassFromString(@"ADBannerView");
if (classAdBannerView != nil) {
self.adBannerView = [[[classAdBannerView alloc] initWithFrame:CGRectZero] autorelease];
[adBannerView setRequiredContentSizeIdentifiers:[NSSet setWithObjects: ADBannerContentSizeIdentifierPortrait, ADBannerContentSizeIdentifierLandscape, nil]];
if (UIInterfaceOrientationIsLandscape([UIDevice currentDevice].orientation)) {
[adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierLandscape];
} else {
[adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierPortrait];
}
[adBannerView setFrame:CGRectOffset([adBannerView frame], 0, -[self getBannerHeight])];
[adBannerView setDelegate:self];
[self.view addSubview:adBannerView];
}
}
- (void)fixupAdView:(UIInterfaceOrientation)toInterfaceOrientation {
if (adBannerView != nil) {
if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
[adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierLandscape];
} else {
[adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierPortrait];
}
[UIView beginAnimations:@"fixupViews" context:nil];
if (adBannerViewIsVisible) {
CGRect adBannerViewFrame = [adBannerView frame];
adBannerViewFrame.origin.x = 0;
adBannerViewFrame.origin.y = 0;
[adBannerView setFrame:adBannerViewFrame];
CGRect contentViewFrame = contentView.frame;
contentViewFrame.origin.y = [self getBannerHeight:toInterfaceOrientation];
contentViewFrame.size.height = self.view.frame.size.height - [self getBannerHeight:toInterfaceOrientation];
contentView.frame = contentViewFrame;
} else {
CGRect adBannerViewFrame = [adBannerView frame];
adBannerViewFrame.origin.x = 0;
adBannerViewFrame.origin.y = -[self getBannerHeight:toInterfaceOrientation];
[adBannerView setFrame:adBannerViewFrame];
CGRect contentViewFrame = contentView.frame;
contentViewFrame.origin.y = 0;
contentViewFrame.size.height = self.view.frame.size.height;
contentView.frame = contentViewFrame;
}
[UIView commitAnimations];
}
}
#pragma mark -
#pragma mark ADBannerViewDelegate
- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
if (!adBannerViewIsVisible) {
adBannerViewIsVisible = YES;
[self fixupAdView:[UIDevice currentDevice].orientation];
}
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
NSLog(@"the failed error is %@",error);
if (adBannerViewIsVisible)
{
adBannerViewIsVisible = NO;
[self fixupAdView:[UIDevice currentDevice].orientation];
}
//NSLog(@"bannerView:didFailToReceiveAdWithError: %@",[error localizedDescription]);
}
how to solve this problem
推荐答案
您将在Simulator或设备中随机收到此错误消息,以便在没有iAd可用时测试您的应用及其行为(使用其他广告隐藏AdView供应商......)。但它不是来自Simulator / iAd framework / iAd网络的错误:它是一个可以进行更好测试的功能。
You will randomly get this error message in Simulator or device, so that you can test your app and its behavior when no iAd is available (hidding the AdView, using another ad provider...). But it's not a bug from Simulator / iAd framework / iAd network: it's a feature to make better tests.
此外,在部署应用时,你无法获得真正的iAds在测试设备上的测试模式。它必须由Apple审核并从AppStore下载。
Moreover, you cannot get "real" iAds when deploying your app in test mode on test device. It has to be reviewed by Apple and downloaded from the AppStore.
这篇关于iAds不适用于模拟器和设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!