title: Make delegate for iAd banners in storyboard based Tab Bar app
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/11655953/make-a-shared-delegate-for-iad-in-my-tabbar-application-using-xcode-4-with-story">Make a shared delegate for iAd in my TabBar application using XCode 4 with storyboard</a>  </p>
  </blockquote>
  
  
  
  <p>I'm making a storyboard app and in the storyboard I put a Tab Bar Controller and added 4 tabs: 2 navigation controllers going to tableviews and two regular views. All linked with the tab bar controller. 
  This is the storyboard: <a href="http://www.flickr.com/photos/80427098@N07/7646756626/in/photostream" rel="nofollow noreferrer">Storyboard</a></p>
  
  <p>First, I just placed iAds at bottom of each of the 4 views in the storyboard and connected with these codes in the </p>
  
  <p>FistTableViewController, SecondTableViewController, FirstViewController and SecondViewController </p>
  
  <p>.h:</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  #import &lt;iAd/iAd.h&gt;
  
  @interface MasterViewController : UITableViewController{
  NSMutableArray *menu;
  ADBannerView *banner;
  }
  
  @property (nonatomic, assign) BOOL bannerIsVisible;
  @property (nonatomic, retain) IBOutlet ADBannerView *banner; 
  </code></pre>
  
  <p>.m:</p>
  
  <pre><code>@implementation MasterViewController
  
  @synthesize banner, bannerIsVisible;
  
  -(void)bannerViewDidLoadAd:(ADBannerView *)abanner {
      if (!self.bannerIsVisible) {
      [UIView beginAnimations:@"animatedAdBannerOn" context:NULL];
      banner.frame = CGRectOffset(banner.frame, 0.0, 50.0);
      [UIView commitAnimations];
      self.bannerIsVisible = YES;
      }
  }
  
  -(void)bannerView:(ADBannerView *)abanner didFailToReceiveAdWithError:(NSError *)error {
  if (!self.bannerIsVisible) {
      [UIView beginAnimations:@"animatedAdBannerOff" context:NULL];
      banner.frame = CGRectOffset(banner.frame, 0.0, -320.0);
      [UIView commitAnimations];
      self.bannerIsVisible = NO;
  }
  }
  </code></pre>
  
  <p>But I need a shared delegate for them so they aren't visible at the same time.
  I've read the documentation and seen the iAd suite sample codes but it's a very different case from my project because my Tab Bar is in the storyboard and I use separate views for all my tabs.</p>
  
  <p>So how can I make the magic of having one banner visible, placed over the Tab Bar all the time in my app? The Tab Bar is in the storyboard only and not subclassed. </p>
  
  <p>This is the storyboard: <a href="http://www.flickr.com/photos/80427098@N07/7646756626/in/photostream" rel="nofollow noreferrer">Storyboard</a></p>