不推荐使用ADBannerContentSizeIdentifier320x50 ..现在怎么办? [英] ADBannerContentSizeIdentifier320x50 deprecated.. now what?

查看:140
本文介绍了不推荐使用ADBannerContentSizeIdentifier320x50 ..现在怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iOS 4.2中不推荐使用以下常量

The following constant is deprecated in iOS 4.2

ADBannerContentSizeIdentifier320x50

因此,对于已经发布的应用程序,这将成为未来操作系统版本中的一个问题。

So for an app that is already released will this be a problem in future OS versions.

在iOS中4.2他们介绍了

In iOS 4.2 they introduced

ADBannerContentSizeIdentifierPortrait

如果我想同时支持iOS 4.0和iOS 4.2,我应该怎么做。

If I want to support both iOS 4.0 and iOS 4.2 how should I go about it.

推荐答案

你必须检查常量是否可用。这是一个解决方案

You'll have to put in checks whether the constants are available or not. Here's one solution

Class cls = NSClassFromString(@"ADBannerView");
if (cls) {

    if (&ADBannerContentSizeIdentifierPortrait != nil) {
        kTabnavADBannerContentSizeIdentifierPortrait = 
                                            ADBannerContentSizeIdentifierPortrait;
    } else {
        kTabnavADBannerContentSizeIdentifierPortrait = 
                                            ADBannerContentSizeIdentifier320x50;
    }

    if (&ADBannerContentSizeIdentifierLandscape != nil) {
        kTabnavADBannerContentSizeIdentifierLandscape = 
                                            ADBannerContentSizeIdentifierLandscape;
    } else {
        kTabnavADBannerContentSizeIdentifierLandscape = 
                                            ADBannerContentSizeIdentifier480x32;
    }

    ADBannerView *adView = [[cls alloc] initWithFrame:CGRectZero];
    adView.requiredContentSizeIdentifiers = [NSSet setWithObjects:
                                             kTabnavADBannerContentSizeIdentifierPortrait,
                                             kTabnavADBannerContentSizeIdentifierLandscape,
                                             nil];

    // Set the current size based on device orientation
    adView.currentContentSizeIdentifier = kTabnavADBannerContentSizeIdentifierPortrait;
    adView.delegate = self;

    adView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin |
                               UIViewAutoresizingFlexibleRightMargin;

    // Set intital frame to be offscreen
    CGRect bannerFrame =adView.frame;
    bannerFrame.origin.y = self.view.frame.size.height;
    adView.frame = bannerFrame;

    self.bannerView = adView;
    [self.view addSubview:adView];
    [adView release];
}

这篇关于不推荐使用ADBannerContentSizeIdentifier320x50 ..现在怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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