我有带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];
答案 0 :(得分:0)
EXC_BAD_ACCESS可能是因为广告视图在控制器中设置为nil。
检查您是否已将Interface Builder中的AdMob视图附加到视图控制器中的视图属性。