2013-05-07 43 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