AdWhirl 轮换使用

发布于 2024-12-09 07:25:39 字数 463 浏览 0 评论 0原文

我正在尝试旋转 AdWhirl 横幅视图。 AdWhirl 提供的唯一文档是:

6.2 设备方向 包括 iAd 在内的一些广告网络会根据设备方向改变其广告尺寸。 如果您的应用支持旋转,您必须通过在 UIViewController 的 should/willAutorotateToInterfaceOrientation: 实现中调用 AdWhirlView.rotateToOrientation: 将方向更改转发到 AdWhirlView,然后按照 6.1 进行重新调整。 如果您的应用的方向概念与 UIDevice.orientation 有所不同,您还必须实现 AdWhirlDelegate.adWhirlCurrentOrientation 以返回适当的值。

我正在尝试解决这个问题,到目前为止已正确实现了 adWhirlDidReceiveAd 方法,但我无法正确旋转和/或调整相关广告的大小。

Im trying to rotate the AdWhirl bannerview. The only documentation AdWhirl provides is:

6.2 Device Orientation
Some ad networks including iAd will vary their ad dimensions with device orientation.
If your app supports rotation you must forward orientation changes to AdWhirlView by invoking AdWhirlView.rotateToOrientation: within your UIViewController’s should/willAutorotateToInterfaceOrientation: implementation and then refit as per 6.1.
If your app’s notion of orientation somehow differs from UIDevice.orientation you must also implement AdWhirlDelegate.adWhirlCurrentOrientation to return the appropriate value.

I'm trying to figure this out and so far correctly implemented the adWhirlDidReceiveAd method but I can't correctly rotate and/or resize the ad in question.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

轮廓§ 2024-12-16 07:25:40

将 AdWhirl 设置在视图底部:此处

使广告在滚动时静态(即TableView):这里

这就是我使用 AdWhirl 旋转广告的方式(可能不是最好的解决方案...):

    awView.transform = CGAffineTransformIdentity;
    awView.transform = CGAffineTransformMakeRotation(degreesToRadian(-90));
    awView.bounds = CGRectMake(0.0, 0.0, 480, 320);

您需要根据您的视图更改坐标。

Set AdWhirl at the bottom of the view: here

Make the ad static when scrolling (i.e. TableView): here

This is how I rotate ads with AdWhirl (probably not the best solution...):

    awView.transform = CGAffineTransformIdentity;
    awView.transform = CGAffineTransformMakeRotation(degreesToRadian(-90));
    awView.bounds = CGRectMake(0.0, 0.0, 480, 320);

You'll need to change the coordinates depending on your view.

时光倒影 2024-12-16 07:25:40

[AdWhirlViewrotateToOrientation] 为每个当前网络适配器调用rotateToOrientation 方法。
但是,某些网络适配器不会覆盖此方法。此方法的默认实现不执行任何操作。
因此,您需要重写rotateToOrientation方法。

接下来是 AdMob 网络适配器的示例实现。

AdWhirlAdapterGoogleAdMobAds.m

-(void)rotateToOrientation:(UIInterfaceOrientation)orientation {

    GADBannerView* adMobView;
    adMobView = (GADBannerView*)adNetworkView;

    switch (orientation) {
        case UIInterfaceOrientationPortrait:
        case UIInterfaceOrientationPortraitUpsideDown:
            adMobView.adSize = kGADAdSizeSmartBannerPortrait;
            break;
        case UIInterfaceOrientationLandscapeLeft:
        case UIInterfaceOrientationLandscapeRight:
            adMobView.adSize = kGADAdSizeSmartBannerLandscape;
            break;
        default:
            break;
    }
}

[AdWhirlView rotateToOrientation] calls rotateToOrientation method for each current network adapter.
However, some network adapter does't override this method. Default implementation of this method does nothing.
So, you need to override rotateToOrientation method.

Next is a sample implementation for network adapter for AdMob.

AdWhirlAdapterGoogleAdMobAds.m

-(void)rotateToOrientation:(UIInterfaceOrientation)orientation {

    GADBannerView* adMobView;
    adMobView = (GADBannerView*)adNetworkView;

    switch (orientation) {
        case UIInterfaceOrientationPortrait:
        case UIInterfaceOrientationPortraitUpsideDown:
            adMobView.adSize = kGADAdSizeSmartBannerPortrait;
            break;
        case UIInterfaceOrientationLandscapeLeft:
        case UIInterfaceOrientationLandscapeRight:
            adMobView.adSize = kGADAdSizeSmartBannerLandscape;
            break;
        default:
            break;
    }
}
余生一个溪 2024-12-16 07:25:40

在 UIViewController 实现中,添加 shouldAutorotateToInterfaceOrientation: ,如下所示:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    if (interfaceOrientation is supported)
    {
        [adWhirlView_ rotateToOrientation:interfaceOrientation];
        return YES;
    }
    else
    {
        return NO;
    }
}

请注意,只要实现了 shouldAutorotateToInterfaceOrientation: ,AdWhirlView 将随布局的其余部分一起旋转。但是,调用rotateToOrientation:将告诉AdWhirlView将方向变化信号转发到广告,以便单个广告网络可以根据需要优化广告的横向效果。

In your UIViewController implementation, add the shouldAutorotateToInterfaceOrientation: like so:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    if (interfaceOrientation is supported)
    {
        [adWhirlView_ rotateToOrientation:interfaceOrientation];
        return YES;
    }
    else
    {
        return NO;
    }
}

Note that as long as shouldAutorotateToInterfaceOrientation: is implemented, the AdWhirlView will rotate with the rest of the layout. However, calling rotateToOrientation: will tell the AdWhirlView to forward an orientation change signal to the ad so that an individual ad network can optimize the ad for landscape if it chooses.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文