0

How to add iAd below the Tab bar, I have added tab bar in rootviewcontroller

self.window.rootViewController = tabBarController;

For a any single view controller adding iAd in viewController by

 [self.contentView addSubview:viewController1.view]; 
 [self.view addSubview:contentView];
 [self.view addSubview:adBannerView];

is working , but the code for tab bar controller

[self.contentView addSubview:tabBarcontroller.view]; 
[self.view addSubview:contentView];

the tab bar controller not loaded, How to add this, thanks in adv

Gobi M
  • 3,243
  • 5
  • 32
  • 47

3 Answers3

2

The best is that you follow the pattern described in iAD suite (a sample code on Apple site). the best advantage that you get is that you don't lost the banner while changing view controller. The idea is that you have an instance of a BannaerManager that shares its iAD banner with a visible BannerViewController that is a container for you VC.

Andrea
  • 26,120
  • 10
  • 85
  • 131
  • I believe the link has changed in late 2015. Here is the new one: http://developer.apple.com/library/ios/#samplecode/iAdSuite/Introduction/Intro.html – Ilya Vinogradov Mar 14 '16 at 18:40
1

Solved by,created a seperate view controller similar to mentioned in Example iAdsuit

Try to pass your tab bar controller to banner view controller by

self.window.rootViewController = [[BannerViewController alloc]initWithContentViewController:tabBarController];
Gobi M
  • 3,243
  • 5
  • 32
  • 47
0

If you want the banner to persist between the tabs and not disappear when rapidly switching tabs, you've got to do the iAd Suite approach: http://developer.apple.com/library/ios/#samplecode/iAdSuite/Introduction/Intro.html

Moreover, you have to have a relationship segue from your tab bar controller to a View Controller that has container view embedded into it. Do that in your storyboard. Also, you need to set Custom Class to BannerViewController for each tab, and embed your content into the embedded view. Take a look at this post for details on how to do it it the Storyboard: https://stackoverflow.com/a/16205420/5007500

If you are not using Storyboard - you need to set BannerViewController as parent view controller for each of your tabs.

Community
  • 1
  • 1
Ilya Vinogradov
  • 746
  • 6
  • 7