将 AdWhirl 视图添加到 tabBarController



我正在尝试将Adwhirl视图添加到当前iOS应用程序的顶部。该应用程序由五个不同的视图组成,这些视图都由单个 TabBarController 控制。任何人都可以编写一个简短的教程来显示实现这一目标所需的代码吗?我已经查看并尝试了很多解决方案,但没有一个能让它工作。

以下是我目前对问题的尝试,我没有收到错误,但我在屏幕上没有看到任何不同的东西。提前谢谢。

@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 {

}
您可能

不应该将子视图添加到普通的UITabBar,如果您需要自定义选项卡栏的布局,您可能需要在此处查看一些替换: http://cocoacontrols.com/

我认为与其向 UITabBar 添加子视图,不如考虑制作类似于 GADBannerView 单例的东西,然后您可以将其添加到每个 o 中您的UITabBarController包含ViewControllers

因此,您可以轻松设置单例(这里有另一个StackOverflow问题,讨论了如何为AdMob广告执行此操作,使其与AdWhirl配合使用应该是微不足道的)。

然后只需在UITabBarController中添加一些ViewControllers,执行以下操作:

  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];

相关内容

  • 没有找到相关文章

最新更新