iAdを取得しようとするアプリがあり、失敗した場合はAdMob広告が読み込まれます。それはiPhone上で完全に動作しますが、iPadで実行すると、アプリの読み込みを妨げる連続的なループが発生します。ここにいくつかのコードがあります:iPadでself.addSubViewが動作しない
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
@try {
NSLog(@"Ad Error, looking for AdMob Ad...");
// Create a view of the standard size at the bottom of the screen.
bannerView_ = [[GADBannerView alloc]
initWithFrame:CGRectMake(0.0,
self.view.frame.size.height -
GAD_SIZE_320x50.height,
GAD_SIZE_320x50.width,
GAD_SIZE_320x50.height)];
// I know the banner size is incorret for iPad but it's only supposed to run
// on iPad in compatibility mode and changing doesn't help
// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
bannerView_.adUnitID = @"XXXXXXX";
// 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_];
GADRequest *admobRequest = [GADRequest request];
admobRequest.testDevices = [NSArray arrayWithObjects:
GAD_SIMULATOR_ID,
nil];
// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest: admobRequest];
[iAdBanner setHidden: YES];
[bannerView_ setHidden: NO];
}
@catch (NSException *e) {
NSLog(@"Exception: %@", e);
}
@finally {
}
}
NSLog
は継続的に印刷され、アプリケーションは読み込まれません。
012-02-24 21:58:38.991 TrophyConverter Free[2948:15e03] Ad Error, looking for AdMob Ad...
2012-02-24 21:58:38.992 TrophyConverter Free[2948:15e03] Ad Error, looking for AdMob Ad...
2012-02-24 21:58:38.994 TrophyConverter Free[2948:15e03] Ad Error, looking for AdMob Ad...
誰でもこれを経験していますか?どのように私はそれを来るのですか? bool
を使用して連続ログ印刷を停止してアプリを読み込むことはできましたが、広告は表示されませんでした。
編集:私は、これはAdMobのビューを追加する部分であるので、便利ではありません。このライン
[self.view addSubview:bannerView_];
を削除すると 問題が完全に消えます。
また、ビルドターゲットをiPhoneアプリではなく普遍的なアプリに変更しようとしました。これで問題は解決しましたが、普遍的なアプリにならないようにするためにレイアウトは作成されていません。
エラーは何ですか? – MyztikJenz
@MyztikJenzエラーはありません。didFailToReceiveAdWithErrorは一度呼び出されたままです。[self.view addSubView:bannerView_]に達しました。それは終わりのないループのようなものです。最終的に私はEXC_BAD_ACCESSを取得し、デバッグ中にself.viewを見ることができないので、それはそれと関係があると思います。私はARCを使用していますが、初期のリリースや何もありません。 – Peter
@MyztikJenzアップルからクラッシュログがあります。私はあなたが彼らのために働いていることに気づきました:) – Peter