1

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.

Anand
  • 4,182
  • 6
  • 42
  • 54

2 Answers2

3

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];
}
lostInTransit
  • 70,519
  • 61
  • 198
  • 274
1

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

SentineL
  • 4,682
  • 5
  • 19
  • 38
  • Sorry this is not true. As I have set deployment target to 3.1.2. The above mentioned does not warn or throw error during compile time – Anand Nov 22 '11 at 09:47
  • Sorry my poor english, cant understand this. You seted deployment target to 3.1.2, and there was no arror/warnings... right? Is this a problem? – SentineL Nov 22 '11 at 10:15
  • Yes no errors/warning. But this is not good as my code crashes in iOS 4.0 and 4.1 if I use new constants introduced in iOS 4.2 – Anand Nov 22 '11 at 10:31
  • I had same problem with video camera. iPone 3G has no video camera, so my app crashed without warning. to avoid this, you should use deprecated constats ignoring warnings about this. There can be worst: they could be not just "deprecated": thay could be completely deleted from SDK, so there will be no warnings: there will be errors. In this bad luck case, you will need to make whatever you whant using another tools... Or, stop supporting iOS 3. Even my old iPhone 3G has iOS 4.2... may be you should think about this. – SentineL Nov 22 '11 at 10:58
  • That is why you should put in conditional checks if your app supports older OS devices (see my answer below). This way it won't crash. Also ensure you do weak-linking. – lostInTransit Nov 24 '11 at 11:59