English 中文(简体)
Admob in iPhone with Tabbar and TableView
原标题:

I m having tab bar with 5 buttons. Out of 5 tabs, 2 are table views which uses navigation controller for showing sub views on click of cell. Above the tab bar, in each view I left some space for ads using "Admob". I m adding ads using IB. But its giving EXC_BAD_ACCESS when its reaching "adMobAd = [AdMobView requestAdWithDelegate:self];" in AdViewController.m

I m using following lines of code to add views to tab bar view. In my code, I just added ads to LatestNews only. Can some one help me out of this problem.

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]; 
问题回答

The EXC_BAD_ACCESS is likely because the ad view is set to nil in the controller.

Check that you ve attached the AdMob view in Interface Builder to a view attribute in your view controller.





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签