1

私は5つのボタンを持つタブバーを持っています。5 つのタブのうち 2 つは、セルのクリック時にサブ ビューを表示するためにナビゲーション コントローラーを使用するテーブル ビューです。タブ バーの上に、各ビューに「Admob」を使用した広告用のスペースを残しました。IB を使用して広告を追加しています。しかし、「adMobAd = [AdMobView requestAdWithDelegate:self];」に到達すると、EXC_BAD_ACCESS が返されます。AdViewController.m で

次のコード行を使用して、ビューをタブ バー ビューに追加しています。私のコードでは、LatestNews のみに広告を追加しました。誰かがこの問題から私を助けることができますか.

UINavigationController *localNavigationController;

// create tab bar controller and array to hold the view controllers
tabBarController = [[UITabBarController alloc] init];
NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:5];

// setup the first view controller (Root view controller)
LatestNews* latestNewsController;
latestNewsController = [[LatestNews alloc] initWithTabBar];



 // create the nav controller and add the root view controller as its first view
  localNavigationController = [[UINavigationController alloc] initWithRootViewController:latestNewsController];

  // add the new nav controller (with the root view controller inside it)
  // to the array of controllers
  [localControllersArray addObject:localNavigationController];

  // release since we are done with this for now
  [localNavigationController release];
  [latestNewsController release];

  // setup the second view controller just like the first
  Forums* forumsController;
  forumsController = [[Forums alloc] initWithTabBar];

  localNavigationController = [[UINavigationController alloc] initWithRootViewController:forumsController];
  [localControllersArray addObject:localNavigationController];
  [localNavigationController release];
  [forumsController release];

 RecipeList* recipesController = [[RecipeList alloc] initWithTabBar];
 localNavigationController = [[UINavigationController alloc] initWithRootViewController:recipesController];
 [localControllersArray addObject:localNavigationController];
 [localNavigationController release];
 [recipesController release];

 //Setup Connect view
 Connect* cnt = [[Connect alloc] initWithTabBar];
 [localControllersArray addObject:cnt];
 [cnt release];

 //Setup Subscribe View
 Subscribe* scribe = [[Subscribe alloc] initWithTabBar];
 [localControllersArray addObject:scribe];
 [scribe release];

  // load up our tab bar controller with the view controllers
  tabBarController.viewControllers = localControllersArray;

  [localControllersArray release];
  [window addSubview:tabBarController.view];
  [window makeKeyAndVisible]; 
4

1 に答える 1

0

EXC_BAD_ACCESS は、コントローラーで広告ビューが nil に設定されているために発生する可能性があります。

Interface Builder の AdMob ビューがビュー コントローラーのビュー属性にアタッチされていることを確認します。

于 2010-03-01T15:32:41.557 に答える