Reputation: 179
I am trying to add an Adwhirl view to the top of my current iOS application. The application is composed of five different views, which are all under the control of a single TabBarController. can anyone write a brief tutorial that shows the code required to achieve this? I have looked through and tried a lot of the solutions out there but none of them are making it work.
Below is my current attempt at the problem, I don't get errors but I don't see anything different on the screen. Thanks in advance.
@implementation idoubs2AppDelegate
@synthesize window;
@synthesize tabBarController;
@synthesize contactsViewController;
@synthesize messagesViewController;
@synthesize adwhirlview = adview;
static UIBackgroundTaskIdentifier sBackgroundTask = UIBackgroundTaskInvalid;
static dispatch_block_t sExpirationHandler = nil;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
AdWhirlView *adView = [AdWhirlView requestAdWhirlViewWithDelegate:self];
[self.tabBarController.view addSubview:adView];
adView.center = CGPointMake(160, 342);
[self.tabBarController.view bringSubviewToFront:adView];
}
- (NSString *)adWhirlApplicationKey {
// return your SDK key
return kSampleAppKey;
}
- (UIViewController *)viewControllerForPresentingModalView {
//return UIWindow.viewController;
return [(idoubs2AppDelegate *)[[UIApplication sharedApplication] delegate] tabBarController];
}
- (void)adWhirlDidReceiveAd:(AdWhirlView *)adWhirlView {
}
Upvotes: 1
Views: 427
Reputation: 2281
I think instead of adding subviews to a UITabBar, you may think of making something similar to a GADBannerView
singleton that you could just then add to each o the ViewControllers
that your UITabBarController
contains.
So you can set up a singleton easily enough (there's another StackOverflow question here that talks about how to do this for AdMob ads and making it work with AdWhirl should be trivial).
Then just add some ViewControllers
into your UITabBarController
doing something like:
UIViewController *viewController1 = [[[FirstViewController alloc]
initWithNibName:@"FirstViewController"
bundle:nil]
autorelease];
UIViewController *viewController2 = [[[SecondViewController alloc]
initWithNibName:@"SecondViewController"
bundle:nil]
autorelease];
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:
viewController1,
viewController2,
nil];
Upvotes: 0
Reputation: 3447
You probably shouldn't be adding subviews to a normal UITabBar, if you need to customize the layout of your tab bar you might want to take a look at some of the replacements here: http://cocoacontrols.com/
Upvotes: 1