0

Possible Duplicate:
Make a shared delegate for iAd in my TabBar application using XCode 4 with storyboard

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: Storyboard

First, I just placed iAds at bottom of each of the 4 views in the storyboard and connected with these codes in the

FistTableViewController, SecondTableViewController, FirstViewController and SecondViewController

.h:

#import <UIKit/UIKit.h>
#import <iAd/iAd.h>

@interface MasterViewController : UITableViewController{
NSMutableArray *menu;
ADBannerView *banner;
}

@property (nonatomic, assign) BOOL bannerIsVisible;
@property (nonatomic, retain) IBOutlet ADBannerView *banner; 

.m:

@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;
}
}

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.

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.

This is the storyboard: Storyboard

Community
  • 1
  • 1
ingenspor
  • 924
  • 2
  • 15
  • 37
  • when you say "over the tab-bar", i presume you don't mean "obscuring" the tab bar, but rather such that the iAd's bottom is the top of the tab-bar, yes? – john.k.doe Jul 25 '12 at 22:33
  • @john.k.doe That's correct! (Ahead of the Tab Bar maybe?) – ingenspor Jul 25 '12 at 22:36
  • have you considered extending UITabBarViewController? it's not that hard to do, and then you could create the delegate and delegate implementation there, and pass the information to each of the viewControllers as they are made frontmost when selected from the tab-bar (and could also adjust their views based on getting information from your tabBarViewController extension. – john.k.doe Jul 25 '12 at 22:43
  • I am new to this so I really haven't concidered so much except searching for information and trying to use the iad suite example code. But I don't make it work because I use a storyboard for my tab bar control and it's confusing with all the timer stuff and xib in the sample.. So any working solution is accepted for me. – ingenspor Jul 25 '12 at 22:52
  • @john.k.doe do you know of a sample code or tutorial or something with an exstended TabBarViewController? By that, do you mean creating a .h/.m for it? – ingenspor Jul 25 '12 at 23:21
  • when i've extended UITabBarViewController myself in the past, i have not done so with the help of a tutorial or anything. just extend it as you see any UIViewController extended in any other samples. – john.k.doe Jul 26 '12 at 01:49

0 Answers0