iOS 6和iAd发出过多警告 [英] iOS 6 and iAds giving too many warnings

查看:77
本文介绍了iOS 6和iAd发出过多警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的iAd代码,我收到有关

Here is my iAd code and I'm getting warnings about

setRequiredContentSizeIdentifiers - deprecated in iOS 6
ADBannerContentSizeIdentifier320x50 - deprecated in iOS 4.2
ADBannerContentSizeIdentifier480x32 - deprecated in iOS 4.2
setCurrentContentSizeIdentifier - deprecated in iOS 6
ADBannerContentSizeIdentifier480x32 - deprecated in iOS 4.2

如何解决此问题,所以不会出现警告.

How do I fix this so there are no warnings.

- (int)getBannerHeight:(UIDeviceOrientation)orientation
{
    if (UIInterfaceOrientationIsLandscape(orientation)) {
        return 32;
    } else {
        return 50;
    }
}

- (int)getBannerHeight
{
    return [self getBannerHeight:[UIDevice currentDevice].orientation];
}

- (void)createAdBannerView
{
    Class classAdBannerView = NSClassFromString(@"ADBannerView");
    if (classAdBannerView != nil) {
        self->adView = [[classAdBannerView alloc]
                              initWithFrame:CGRectZero];
        [adView setRequiredContentSizeIdentifiers:[NSSet setWithObjects:
                                                          ADBannerContentSizeIdentifier320x50,
                                                          ADBannerContentSizeIdentifier480x32, nil]];
        if (UIInterfaceOrientationIsLandscape([UIDevice currentDevice].orientation)) {
            [adView setCurrentContentSizeIdentifier:
             ADBannerContentSizeIdentifier480x32];
        } else {
            [adView setCurrentContentSizeIdentifier:
             ADBannerContentSizeIdentifier320x50];
        }
        [adView setFrame:CGRectOffset([adView frame], 0,
                                             -[self getBannerHeight])];
        [adView setDelegate:self];

        [self.view addSubview:adView];        
    }
}

- (void)fixupAdView:(UIInterfaceOrientation)toInterfaceOrientation
{
    if (adView != nil) {
        if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
            [adView setCurrentContentSizeIdentifier:
             ADBannerContentSizeIdentifier480x32];
        } else {
            [adView setCurrentContentSizeIdentifier:
             ADBannerContentSizeIdentifier320x50];
        }
        [UIView beginAnimations:@"fixupViews" context:nil];
        if (bannerIsVisible) {
            CGRect adBannerViewFrame = [adView frame];
            adBannerViewFrame.origin.x = 0;
            adBannerViewFrame.origin.y = 0;
            [adView setFrame:adBannerViewFrame];
            CGRect contentViewFrame = _contentView.frame;
            contentViewFrame.origin.y =
            [self getBannerHeight:toInterfaceOrientation];
            contentViewFrame.size.height = self.view.frame.size.height -
            [self getBannerHeight:toInterfaceOrientation];
            _contentView.frame = contentViewFrame;
        } else {
            CGRect adBannerViewFrame = [adView frame];
            adBannerViewFrame.origin.x = 0;
            adBannerViewFrame.origin.y =
            -[self getBannerHeight:toInterfaceOrientation];
            [adView setFrame:adBannerViewFrame];
            CGRect contentViewFrame = _contentView.frame;
            contentViewFrame.origin.y = 0;
            contentViewFrame.size.height = self.view.frame.size.height;
            _contentView.frame = contentViewFrame;
        }
        [UIView commitAnimations];
    }
}

推荐答案

您正在使用已弃用的方法/符号.

You are using deprecated methods/symbols.

弃用意味着方法/符号仍在此处,并且通常仍然可以使用,但是在将来的iOS版本中可能会删除它们.

Deprecation means the methods/symbols are still here, and will usually still work, but they may be removed on future iOS versions.

官方文档总是列出不推荐使用的方法/符号,并且通常会提供新的方法/符号.

The official documentation always list the deprecated methods/symbols, and usually provides the new ones.

所以我不想这么说,不过,只是阅读文档.

So I hate to say this, as an answer, but just read the doc.

关于iOS 6的警告还不错,因为iOS 6相当新.
但如果可以的话,还要修复它们.完成的工作已经完成.

Warnings about iOS 6 are not too bad, as iOS 6 is pretty new.
But also fix them if you can. What is done is done.

但是您似乎也在使用iOS 4.2弃用的方法/符号!
这实际上是一个问题.目前对iOS 4的支持正在下降,因此您的实际代码可能无法长期使用.

But it seems you are also using methods/symbols that were deprecated on iOS 4.2!
This is actually a concern. iOS 4 support is currently dropping, so your actual code might not work for long.

因此,请再次阅读文档,了解新方法并修复代码.

So read the doc (again), learn about the new methods, and fix your code.

例如:

ADBannerContentSizeIdentifier320x50 - deprecated in iOS 4.2

文档中,您可以阅读以下内容:

In the documentation, you can read the following:

ADBannerContentSizeIdentifier320x50指示标题视图为 320点乘50点.此尺寸在iPhone上用于 肖像广告. (不推荐使用. 而不是ADBannerContentSizeIdentifierPortrait.)在iOS 4.0中可用 然后.在iOS 4.2中已弃用.宣告中 ADBannerView_Deprecated.h.

ADBannerContentSizeIdentifier320x50 Indicates that the banner view is 320 points by 50 points in size. This size is used on iPhone for portrait advertisements. (Deprecated. Use ADBannerContentSizeIdentifierPortrait instead.) Available in iOS 4.0 and later. Deprecated in iOS 4.2. Declared in ADBannerView_Deprecated.h.

因此,只需使用ADBannerContentSizeIdentifierPortrait即可代替ADBannerContentSizeIdentifier320x50.
ADBannerContentSizeIdentifier480x32相同.改为使用ADBannerContentSizeIdentifierLandscape.

So instead of ADBannerContentSizeIdentifier320x50, simply use ADBannerContentSizeIdentifierPortrait.
Same for ADBannerContentSizeIdentifier480x32. Use ADBannerContentSizeIdentifierLandscape instead.

这样您就可以安全了,并且不再对此有任何警告.

You'll then be safe, and you'll no longer have a warning about this.

然后简单地对其他符号执行相同的操作.

Then simply do the same for the other symbols.

编辑

如您的评论所述,ADBannerContentSizeIdentifierPortraitADBannerContentSizeIdentifierLandscape在iOS 6上也已弃用.

As stated on your comment, ADBannerContentSizeIdentifierPortrait and ADBannerContentSizeIdentifierLandscape are also deprecated on iOS 6.

这与setCurrentContentSizeIdentifiersetRequiredContentSizeIdentifiers的弃用有关.

Apple建议不再使用该方法,并使用iOS的自动调整大小功能.

Apple recommends not to use that approach anymore, and use the auto-resizing capabilities of iOS.

这篇关于iOS 6和iAd发出过多警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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