2013-05-07 56 views
0

我開發了一個應用程序,我想添加Admob。
我無法運行Admob測試Bannerview。Admob在Xcode上遇到錯誤

代碼:

// Create a view of the standard size at the top of the screen. 
// Available AdSize constants are explained in GADAdSize.h. 
bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner]; 
//bannerView_.frame = CGRectMake(0, 200, 320, 50); 


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

// 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.view2 addSubview:bannerView_]; 


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

和錯誤是:

tableViewKullanimi[13107:c07] <Google> To get test ads on this device, call: 
request.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID, nil]; 
2013-05-07 17:29:28.154 tableViewKullanimi[13107:c07] -[GADObjectPrivate changeState:]: unrecognized selector sent to instance 0xa360320 
2013-05-07 17:29:28.155 tableViewKullanimi[13107:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GADObjectPrivate changeState:]: unrecognized selector sent to instance 0xa360320' 
*** First throw call stack: 
(0x1ed2012 0x1a85e7e 0x1f5d4bd 0x1ec1bbc 0x1ec194e 0x7cc45 0x7e7c6 0x7c1ae 0x2da1 0xaab1c7 0xaab232 0x9fa3d5 0x9fa76f 0x9fa905 0xfb33ab6 0xa03917 0x9c796c 0x9c894b 0x9d9cb5 0x9dabeb 0x9cc698 0x1d1cdf9 0x1d1cad0 0x1e47bf5 0x1e47962 0x1e78bb6 0x1e77f44 0x1e77e1b 0x9c817a 0x9c9ffc 0x27fd 0x2725) 
libc++abi.dylib: terminate called throwing an exception 
+0

此類是UIViewController的子類嗎?如果沒有,則不能將rootviewController設置爲「self」。 – 2013-05-08 00:15:43

+0

看到這個鏈接http://stackoverflow.com/questions/12635283/admob-crashes-with-gadobjectprivate-changestate-unrecognized-selector – Deepesh 2013-06-11 07:04:09

回答

1

添加-all_load標記爲 「其它鏈接器標記」,它應該工作。 必須在AdMob中啓用「測試標語」www