How to make iAds work on a 3.0 + iPhone-iPad app?
I created a universal app for the iPhone-iPad. I'm only working on the iPhone part at the moment. In the header file for the view controller for the iPhone one, I import the adbanner header and create an adbannerview variable with a matching property. I don't make it in the nib file but rather check at run time if the class exists, if it does, I create an adbanner progr开发者_高级运维ammily and then attach the adbannerview variable to it so I can refer to it inside other functions. Everything works on the 4.0 simulator. I also weak linked the iad class.
So if I take the same code to an earlier version of xcode and try to run using the 3.0 sim, it gives all these errors saying I can't import the header and make the adbannerview variable and the property, how do I get around this?
Thanks. If you need more details or my code, just ask.
The AdLib Framework and iAds are only available in iOS > 4.0. For example, see the docs for ADBannerView:
Availability Available in iOS 4.0 and later.
If you are trying to build the app on an older version of the sdk (not just run the binary on a older device) and are getting errors when you try to import the headers like your question suggests, you could try wrapping the imports that fail in a #ifdef directive that tests for the availability macros from Availability.h, something like:
#ifdef __IPHONE_4_0
// iOS 4 specific imports here
#endif
精彩评论