gpt4 book ai didi

ios - iAd 未显示在用户设备上,但显示在我的 Xcode 部署设备上

转载 作者:行者123 更新时间:2023-11-29 12:09:56 24 4
gpt4 key购买 nike

我做了一个只支持横向模式的应用程序,它包含一个 iAd 横幅。横幅在我的开发设备上显示得很好,带有消息“您已连接到 iAd 网络”。

我的应用程序在 App Store 上的第一天就收到了大约 100 次下载,但没有收到 iAd 横幅请求。我从 App Store 下载了我的应用程序,但仍然收到“您已连接到 iAd 网络”消息。我从非开发设备下载应用程序,iAd 根本没有出现。

我的实现有问题吗?

.h

#import <iAd/iAd.h>

@interface `enter code here`ViewController : UIViewController <UIAlertViewDelegate,MFMailComposeViewControllerDelegate,ADBannerViewDelegate>
{

BOOL _bannerIsVisible;
ADBannerView *_adBanner;

.m

- (void)iAdInit:(BOOL) isInit {
int width;
int height;

if([[NSUserDefaults standardUserDefaults] integerForKey:@"removeAd"]!=1)
{
if([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad)
{
width=1024;
height=66;
}
else//iphone or ipad
{
width=480;
height=32;
}

if(isInit)
{
_adBanner = [[ADBannerView alloc] init];
_adBanner.delegate = self;
[_adBanner setFrame:CGRectMake(0, self.view.frame.size.height, width,height)];
}
}
}

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self iAdInit:1];
}

- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
NSLog(@"Load AD");
if (!_bannerIsVisible)
{
// If banner isn't part of view hierarchy, add it
if (_adBanner.superview == nil)
{
[self.view addSubview:_adBanner];
}
banner.hidden=NO;

[UIView beginAnimations:@"animateAdBannerOn" context:NULL];
// Assumes the banner view is just off the bottom of the screen.
banner.frame = CGRectOffset(banner.frame, 0, -banner.frame.size.height);
[self moveOverBannerElements:-banner.frame.size.height];
[UIView commitAnimations];

_bannerIsVisible = YES;
}
}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
NSLog(@"Can't Load AD");

if (_bannerIsVisible)
{
[UIView beginAnimations:@"animateAdBannerOff" context:NULL];
// Assumes the banner view is placed at the bottom of the screen.
banner.frame = CGRectOffset(banner.frame, 0, banner.frame.size.height);
[self moveOverBannerElements:banner.frame.size.height];
[UIView commitAnimations];

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
banner.hidden=YES;
});

_bannerIsVisible = NO;
}
}

NSLayoutConstraint *constraint;
NSLayoutConstraint *constraint2;

-(void)moveOverBannerElements:(float) offsetYPosition {
if(constraint){[self.view removeConstraint: constraint];}
if(constraint2){[self.view removeConstraint: constraint2];}

if(offsetYPosition<0){
constraint = [NSLayoutConstraint constraintWithItem:resolutionSegment attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0f constant:offsetYPosition-4];
[self.view addConstraint:constraint];

constraint2 = [NSLayoutConstraint constraintWithItem:fpsSegment attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0f constant:offsetYPosition-4];
[self.view addConstraint:constraint2];
}
}
-(void) removeAd {
[[NSUserDefaults standardUserDefaults] setInteger:1 forKey:@"removeAd"];
[[NSUserDefaults standardUserDefaults] synchronize];

///return elements to defaul position
if(constraint){[self.view removeConstraint: constraint];}
if(constraint2){[self.view removeConstraint: constraint2];}
///return elements to defaul position

_adBanner.hidden=YES;
NSLog(@"remove ad");
}

最佳答案

在您的申请获得批准并在 App Store 上发布后,iAd Network 团队将对其进行审核。一旦他们批准,广告将被传送到您的应用程序。这有时最多需要 7 个工作日。

如果您在测试应用程序时收到蓝色的 You're Connected To iAd 广告,那么您就可以开始了。


来自Contact Us页:(iAd App Network>一般 iAd App Network 问题>加入 iAd App Network)

After your app has been approved and is in the Ready for Sale state, it also will be reviewed by iAd to determine the app’s appropriateness for receiving ads from iAd advertisers. After your app has been approved by iAd, you can start earning revenue for ads that run in your app.

关于ios - iAd 未显示在用户设备上,但显示在我的 Xcode 部署设备上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33753840/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com