ADBannerContentSizeIdentifier320x50 deprecated.. now what?

廉价感情. 提交于 2019-12-01 13:08:37

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

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

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