如何獲得iAds能夠在iPhone 2G上運行的應用程序。我知道這個設備不支持iAds,因此我希望代碼不被執行。iAd在iPhone 2G(以及其他非iOS 4設備)上的應用程序
這是我的一些代碼。 .h文件:
#import <UIKit/UIKit.h>
#ifdef __IPHONE_4_0
#import <iAd/iAd.h>
#endif
@interface ViewController : UIViewController
#ifdef __IPHONE_4_0
<ADBannerViewDelegate>
#endif
{
#ifdef __IPHONE_4_0
ADBannerView *adView;
#endif
...
在.m文件我都iAd的周圍來編碼,像這樣:
#ifdef __IPHONE_4_0 //iAd Code
adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.frame = CGRectOffset(adView.frame, 0, 500);
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
[self.view addSubview:adView];
adView.delegate = self;
self.bannerIsVisible = NO;
#endif
但是我仍然得到一個錯誤。該應用程序總是崩潰,只會顯示啓動圖像。我得到一個彈出窗口,說:「啓動可執行程序的錯誤'應用程序'啓動遠程程序時出錯:無法獲取進程411的任務。」這裏是控制檯:
GNU gdb 6.3.50-20050815 (Apple version gdb-1518) (Thu Jan 27 08:40:30 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=x86_64-apple-darwin --target=arm-apple-darwin".tty /dev/ttys000
warning: Unable to read symbols from "iAd" (not yet mapped into memory).
target remote-mobile /tmp/.XcodeGDBRemote-6877-41
Switching to remote-macosx protocol
mem 0x1000 0x3fffffff cache
mem 0x40000000 0xffffffff none
mem 0x00000000 0x0fff none
可能的[使用iAd的應用程序與舊iOS兼容]的副本(http://stackoverflow.com/questions/3128457/are-apps-using-iad-compatible-with-older-ios) – 2011-03-19 22:18:06