Objective c 为什么我的iAd横幅不显示?
通过阅读您的问题不确定,但请注意,Apple模拟的IAD不可用。有时候,在广告样本发布之前,你需要尝试多次。有四个要点。首先,您应该在viewDidLoad方法中将横幅定位在屏幕外,因为它在您第一次启动时只会显示一个空帧,并且很可能因此而被拒绝 其次,您设置的横幅视图不正确。我认为帧仍然是零。第三,您没有设置bannerView的代理。请尝试以下操作:Objective c 为什么我的iAd横幅不显示?,objective-c,ios,iad,Objective C,Ios,Iad,通过阅读您的问题不确定,但请注意,Apple模拟的IAD不可用。有时候,在广告样本发布之前,你需要尝试多次。有四个要点。首先,您应该在viewDidLoad方法中将横幅定位在屏幕外,因为它在您第一次启动时只会显示一个空帧,并且很可能因此而被拒绝 其次,您设置的横幅视图不正确。我认为帧仍然是零。第三,您没有设置bannerView的代理。请尝试以下操作: - (void)viewDidLoad { adView = [[ADBannerView alloc] initWithFrame:
- (void)viewDidLoad
{
adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
CGRect adFrame = adView.frame;
adFrame.origin.y = self.view.frame.size.height-adView.frame.size.height;
adView.frame = adFrame;
[self.view addSubview:adView];
}
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
if (!self.bannerIsVisible)
{
self.bannerIsVisible = YES;
}
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
if (self.bannerIsVisible)
{
self.bannerIsVisible = NO;
}
第四,在BannerViewIDLoadAD:method中,您没有将横幅广告设置为动画。试试这个:
-(void)viewDidLoad{
CGRect frame=CGRectZero;
frame.size = [ADBannerView sizeFromBannerContentSizeIdentifier:ADBannerContentSizeIdentifierPortrait];
// Place frame at the bottom edge of the screen out of sight
frame.origin = CGPointMake(0.0, CGRectGetMaxY(self.view.bounds));
// Now to create and configure the banner view
ADBannerView *adView = [[ADBannerView alloc] initWithFrame:frame];
adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
// Set the delegate to self, so that we are notified of ad responses
adView.delegate = self;
[self.view addSubview: adView];
}
当然,如果横幅应该放在屏幕的顶部,您可能会知道需要如何修改,但这会让您朝着正确的方向前进
祝你好运
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
// Get a brand new frame
CGRect newFrame=CGRectZero;
CGPoint frameOrigin=CGPointZero;
// Set the origin
frameOrigin=CGPointMake(0.0, CGRectGetMaxY(self.view.bounds));
newFrame.origin=frameOrigin;
// Set the size
newFrame.size=[ADBannerView sizeFromBannerContentSizeIdentifier:ADBannerContentSizeIdentifierPortrait];
CGFloat bannerHeight = newFrame.size.height;
CGFloat bannerOffset=0.0;
// Determine where the new frame should be
if (!self.bannerIsVisible)
{
// It should be visible, raise it up
bannerOffset=-bannerHeight;
}
CGRect offSetRect=CGRectOffset(newFrame,0.0f,bannerOffset);
[UIView animateWithDuration:0.2
animations:^{banner.view.frame=offSetRect}
completion:^(BOOL finished){
if (bannerOffSet<0){
self.bannerIsVisible=YES;
}else{
self.bannerIsVisible=NO;
}
}
];
}