ADBannerContentSizeIdentifier320x50 deprecated.. now what?

感情迁移 提交于 2020-01-11 07:22:28

问题


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.

In iOS 4.2 they introduced

ADBannerContentSizeIdentifierPortrait

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


回答1:


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];
}



回答2:


develop on lastest iOS target, but set deployment target to 4.0 at your project's build settings and all targets.



来源:https://stackoverflow.com/questions/8223763/adbannercontentsizeidentifier320x50-deprecated-now-what

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!