如何让iAd在3.0 + iPhone-iPad应用程序上运行? [英] How to make iAds work on a 3.0 + iPhone-iPad app?

查看:166
本文介绍了如何让iAd在3.0 + iPhone-iPad应用程序上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为iPhone-iPad创建了一个通用应用程序。我目前只在iPhone上工作。在iPhone的视图控制器的头文件中,我导入了adbanner标头并创建了一个具有匹配属性的adbannerview变量。我不在nib文件中创建它,而是在运行时检查类是否存在,如果存在,我会创建一个adbanner programmily然后将adbannerview变量附加到它,以便我可以在其他函数中引用它。一切都在4.0模拟器上运行。我也弱连接了iad类。

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.

因此,如果我将相同的代码用于早期版本的xcode并尝试使用3.0 sim运行,它会给出所有这些错误说我无法导入标题并制作adbannerview变量和属性,我该如何解决这个问题?

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.

推荐答案

AdLib框架和iAd仅适用于iOS> 4.0。例如,请参阅文档:

The AdLib Framework and iAds are only available in iOS > 4.0. For example, see the docs for ADBannerView:


可用性适用于iOS 4.0和
以后。

Availability Available in iOS 4.0 and later.

如果您尝试在较旧版本的sdk上构建应用程序(而不是仅仅运行二进制文件)当您尝试导入标题时出现错误,如问题所示,您可以尝试在#ifdef指令中包装失败的导入,该指令用于测试Availability.h中的可用性宏,如:

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

这篇关于如何让iAd在3.0 + iPhone-iPad应用程序上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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