【问题标题】:Changing iAd position and placement更改 iAd 位置和展示位置
【发布时间】:2011-12-18 14:56:07
【问题描述】:

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

- (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?

我会很感激任何帮助,这是在转弯!

谢谢。

【问题讨论】:

    标签: objective-c ios cocoa-touch iad ios5


    【解决方案1】:

    将 adview.frame.origin.y 设置为您想要的任何底部,何时您想要它。例如,我的 iad 是在应用程序委托中设置的,然后在我想要的视图控制器中,在 viewwillapear 中,我会使用 adview.frame.origin.x = 0;adview.frame.origin.y = 420; [SharediAdView setframe:adview.frame];

    不同的设置取决于 iphone 3.5 英寸/4 英寸、当前视图控制器中的空间和方向。

    如果您希望将所有内容向上/向下移动,并且不想弄乱量身定制的解决方案,我会尝试以下内容:https://github.com/chrisjp/CJPAdController

    【讨论】:

      【解决方案2】:
      adView.frame = CGRectMake(0.0, 375.0, iAdView.frame.size.width, iAdView.frame.size.height);
      

      使用此代码代替

      adView.frame = CGRectOffset(adView.frame, 0, -50);
      banner.frame = CGRectOffset(banner.frame, 0, 50);
      banner.frame = CGRectOffset(banner.frame, 0, -50);
      

      并根据您的需要更改广告展示位置 (375.0) :)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-11-12
        • 2018-12-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多