PDA

View Full Version : Dilemma: iOS 4 or iPad-support?




Danneman101
Jul 4, 2010, 06:21 AM
Ive got an app that is not adapted to the iPad but will run on it just fine.

I just finished updating the project to SDK 4, including an iAd etc.

But since this update would not run on the iPad, replacing the existing one will reduce my customer-base.

Im guessing most people who dont intend on making a hd-version for iPad have the same dilemma, so what have you done?

Have you gone ahead and updated your app, hoping that the iOS 4 will soon hit the iPad and it will work there?

Or have you uploaded a duplicate of you app, now distributing two apps?



robbieduncan
Jul 4, 2010, 06:29 AM
Update Base SDK to 4.0. Set Target Deployment to 3.0. Use conditional coding techniques to only use 4.0 APIs on 4.0. That way you get iAds on 4.0 based devices and you can still use the same app on the iPad.

Danneman101
Jul 4, 2010, 07:31 AM
Update Base SDK to 4.0. Set Target Deployment to 3.0. Use conditional coding techniques to only use 4.0 APIs on 4.0. That way you get iAds on 4.0 based devices and you can still use the same app on the iPad.

To try this out I made a fresh project without any sdk 4-specific code, but as soon as I added the iAd-framework to the project it wouldnt run in the iPad simulator (immediately exited the app).

So how do I make the inclusion of an entire framework conditional?

And for that matter, how do a make a snippet of code conditional to the os running? How can I in code check the current os?

robbieduncan
Jul 4, 2010, 07:41 AM
If your iAd view is in a nib then you may have remove it and do all of the iAd stuff in code (I don't know: I do all my UI in code).

You will need to Weak Link the iAd framework (see the Apple documentation). Once you have done that you can conditionally use the symbols in the 4.0 SDK as described in the documentation (https://developer.apple.com/iphone/library/documentation/General/Conceptual/iPadProgrammingGuide/StartingYourProject/StartingYourProject.html#//apple_ref/doc/uid/TP40009370-CH9-SW3) (more here (https://developer.apple.com/iphone/library/documentation/DeveloperTools/Conceptual/cross_development/Introduction/Introduction.html#//apple_ref/doc/uid/10000163-BCICHGIE)).

broncopde
Jul 4, 2010, 07:47 AM
Wirelessly posted (iPod touch: Mozilla/5.0 (iPod; U; CPU iPhone OS 3_1_3 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7E18 Safari/528.16)

What is your app? That might help us think about this question with you.

Danneman101
Jul 4, 2010, 10:16 AM
Thanks robbieduncan - I think I got it now :)

For others having the same problem, here are the steps:

1) In xcode, press "Targets" and set "iAd.framework"s (browse under "File Name") "Role" to "Weak".

2) In your m-file, where you initialize your AdBannerView, surround that code with the following code (bold):


Class classAdBannerView = NSClassFromString(@"ADBannerView");
if (classAdBannerView != nil) {

if (!bannerIsVisible)
{
adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.frame = CGRectOffset(adView.frame, 0, 417); // Dont show ad yet
adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifier320x50];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
[self.view addSubview:adView];
adView.delegate=self;
}
}


Apparently the first line tries to create an AdBannerView-class. If it works (ie youre running on ios 4 or later), the if-statement will take you further and set up the iad.

Apparently I did not have to do anything to both the "didFailToReceiveAdWithError" and the "bannerViewDidLoadAd" functions. Just leave them as be.