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