How to make iAds work on a 3.0 + iPhone-iPad app?

ぐ巨炮叔叔 提交于 2019-12-12 01:35:53

问题


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 programmily 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.


回答1:


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


来源:https://stackoverflow.com/questions/3587471/how-to-make-iads-work-on-a-3-0-iphone-ipad-app

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