Iphone 旋转使用

Iphone 旋转使用,iphone,adwhirl,Iphone,Adwhirl,我正在尝试旋转AdWhirl横幅视图。AdWhirl提供的唯一文档是: 6.2设备定向 包括iAd在内的一些广告网络将根据设备方向改变其广告尺寸。 如果您的应用程序支持旋转,则必须通过调用AdWhirlView将方向更改转发到AdWhirlView。旋转方向:在UIViewController的应/将自动旋转指向面方向:实现中,然后按照6.1重新安装。 如果应用程序的方向概念与UIDevice.orientation有所不同,则还必须实现AdWhirlDelegate.adWhirlCurren

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

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


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

在UIViewController实现中,添加shouldAutorotateToInterfaceOrientation:like so:

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

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

在视图底部设置AdWhirl:

滚动时使广告静止(即TableView):

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


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

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

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

AdWhirlAdapterGoogledMobads.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;
    }
}

我注意到它随屏幕旋转,但它还没有调整广告的大小。顺便说一句,我在文档中找不到如何将广告放置在视图底部,并使其在屏幕中保持静态,以便您无法将其滚动到视图之外。在我的情况下,rotateToOrientation的定义中,currAdapter始终为零。。。。。它总是在设置方向之前返回。这是正确的方法吗?因为我无法获得想要的结果?
-(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;
    }
}