2012-02-02 78 views
0

我在iOS應用程序(iPhone和iPad:通用應用程序)中集成了Admob。 在開始時我檢查模擬器上的admob工程,但是當我在設備上安裝應用程序時,應用程序崩潰並且評論admob代碼,應用程序工作正常。幾天後,我取消註釋代碼,並在設備上安裝應用程序,它似乎在這兩個設備上工作,看到不同的2添加橫幅。幾天後,同樣的代碼在設備中崩潰並在模擬器中爲admob工作。現在我評論除了一個屏幕之外的所有屏幕上的Admob代碼,如果我沒有訪問未註釋admob代碼的屏幕,現在應用程序正在工作。在實際的iOS設備上Admob不適用於iOS應用程序,但它適用於模擬器

請給我解決方案,我使用下面的代碼。

AbMob = [[ALLOC的GADBannerView] initWithFrame:方法CGRectMake(0.0,768-50-90, GAD_SIZE_728x90.width, GAD_SIZE_728x90.height)];

AbMob.adUnitID = [Utility getADmobPublisherId]; 
AbMob.rootViewController = self; 

[self.view addSubview:AbMob]; 
GADRequest *r = [[GADRequest alloc] init]; 
r.testing = YES; 
//--------- 
r.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID,@"UDID1",@"UDID2",nil]; 
//---------- 
[AbMob loadRequest:r]; 

在此先感謝。

回答

0

試用此版本。

AbMob = [[GADBannerView alloc] initWithFrame:CGRectMake(
    0.0, 
    768-50-90, 
    GAD_SIZE_728x90.width, 
    GAD_SIZE_728x90.height)]; 

AbMob.adUnitID = [Utility getADmobPublisherId]; 
[AbMob setRootViewController:self]; 

[self.view addSubview:AbMob]; 
GADRequest *r = [GADRequest request]; // This takes care of reference counts for you. 
r.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID, 
              @"UDID1", 
              @"UDID2", 
              nil]; 
[AbMob loadRequest:r]; 
相關問題