2012-09-01 156 views
0

我試圖導入AdMob SDK,但是當我在viewDidLoad方法運行下面的代碼我得到這些錯誤和警告......實施AdMob廣告SDK - iPhone

// Create a view of the standard size at the bottom of the screen. 
// Available AdSize constants are explained in GADAdSize.h. 
bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner]; 

// Specify the ad's "unit identifier." This is your AdMob Publisher ID. 
bannerView_.adUnitID = @"a15030fff8e7e98"; 

// Let the runtime know which UIViewController to restore after taking 
// the user wherever the ad goes and add it to the view hierarchy. 
bannerView_.rootViewController = self; 
[self.view addSubview:bannerView_]; 

// Initiate a generic request to load it with an ad. 
[bannerView_ loadRequest:[GADRequest request]]; 

這裏有錯誤和我收到的警告......什麼是錯的?

xCode

而且,這裏是我的Project Navigator中的AdMob文件...

enter image description here

編輯:我的應用程序啓動時,我現在收到此崩潰...

'NSInvalidArgumentException', reason: '-[GADBannerView private]: unrecognized selector sent to instance 

回答

0

我能想到的第一件事就是轉到項目中的「構建階段」選項卡,然後選中「鏈接二進制庫」框。看看你的「libGoogleAdMobAds.a」是否在那裏。

+0

不,它不在那裏。 –

+0

現在我得到這個崩潰,雖然...'NSInvalidArgumentException',原因:' - [GADBannerView私人]:無法識別的選擇發送到實例 –

+0

然後添加它。點擊+按鈕放在那裏。讓我知道這是否有效。 –

1

將-all_load標誌添加到「其他鏈接器標誌」,它應該工作。