更改iAd位置和位置 [英] Changing iAd position and placement

查看:87
本文介绍了更改iAd位置和位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在查看各种教程和代码片段,尝试实现iAd。我在某种程度上取得了成功,但我需要自定义,我似乎无法解决我需要做些什么来进行更改,有人可以帮忙吗?

I've been looking at various tutorials and code snippets, try to implement iAd. I've been successful to an extent but I need to customise, I can't seem to work out what I need to do to make my changes, can anyone help?

- (void)viewDidLoad
{
adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.frame = CGRectOffset(adView.frame, 0, -50);
adView.requiredContentSizeIdentifiers = [NSSet setWithObjects:ADBannerContentSizeIdentifierPortrait, ADBannerContentSizeIdentifierLandscape, nil];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
[self.view addSubview:adView];
adView.delegate = self;
self.bannerIsVisible = NO;
[super viewDidLoad];

// Do any additional setup after loading the view from its nib.
}

- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
if (!self.bannerIsVisible)
{

    [UIView beginAnimations:@"animateAdBannerOn" context:NULL];
    // banner is invisible now and moved out of the screen on 50 px
    banner.frame = CGRectOffset(banner.frame, 0, 50);
    [UIView commitAnimations];
    self.bannerIsVisible = YES;
}
}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
if (self.bannerIsVisible)
{
    [UIView beginAnimations:@"animateAdBannerOff" context:NULL];
    // banner is visible and we move it out of the screen, due to connection issue
    banner.frame = CGRectOffset(banner.frame, 0, -50);
    [UIView commitAnimations];
    self.bannerIsVisible = NO;
}
}

目前,横幅已加载到顶部一个UIWebView。首先我喜欢它的底部,其次,广告与WebView内容重叠,有什么方法可以在广告加载或消失时推送WebView吗?

As it stands, the banners are loaded at the top of a UIWebView. Firstly I'd like it at the bottom and secondly, the ad overlaps the WebView content, is there any way I can push the WebView when an ad loads or disappears?

我很感激任何帮助,这是绕弯道!

I'd appreciate any help, this is driving round the bend!

谢谢。

推荐答案

将adview.frame.origin.y设置为你想要它的最低点, 时你需要它。例如,我的iad是在app delegate中设置的,然后在我想要的视图控制器中,在viewwillapear中,我使用adview.frame.origin.x = 0; adview.frame.origin.y = 420; [SharediAdView setframe:adview.frame];

set adview.frame.origin.y to however far bottom you want it, when you want it. For instance, my iad is setup in the app delegate, then in the view controller I want, in viewwillapear, I'd use adview.frame.origin.x = 0;adview.frame.origin.y = 420; [SharediAdView setframe:adview.frame];

,差异设置取决于iphone 3.5inch / 4inch,当前视图控制器中的空间,&定向。

with diff settings depending on iphone 3.5inch/4inch, space in the current view controller, & orientation.

如果你宁愿向上/向下移动所有东西,并且不想弄乱定制的解决方案,我会尝试这样的东西: https://github.com/chrisjp/CJPAdController

If you'd rather move everything up/down, and don't want to mess with a tailored solution, I'd try this stuff: https://github.com/chrisjp/CJPAdController

这篇关于更改iAd位置和位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆