how to display test IAd banner in the simulator

随声附和 提交于 2019-11-26 16:44:15
Ankit Vyas

Step 1:

1.import iAd Framework to the Application.

2.Provide #import in the particular controller where you want to show your Add.

3.Provide it’s delegate UIViewController

4.Provide one view to that particular ViewController.Assume I have taken

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

Step 2:

Allocate it in ViewDidLoad method

- (void)viewDidLoad
{
_bannerView = [[ADBannerView alloc] init];
_bannerView.delegate = self;

[super viewDidLoad];
[self.view addSubview:_bannerView];
}

step 3:

Provides it’s delegate methods which i have mention bellowed.

- (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;
}];
}

For More Detail Please refer this link

Rob

Looks like it's an issue on Apple's server side. Make sure your provisioning profile is up to date and make sure your app is registered to receive ads (through itunes connect). I can't see anything wrong with your code.

Check out this link for more.

Firstly you must check if the frame for your banner is given correctly or not.... if thats right, then may be you should check with the proxy settings in your system if you are working from office... You might need to have the download rights to download the content from internet.. This might just be one problem as you have already said that you are doing every thing else correctly...

One more thing AAAAAA.... I think you must first register with apple's iAd network through iTunes connect to receive any ads from them.... I suggest you to check their documentation on iAd's for more clarity...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!