[英]Add AdWhirl view to a 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/
我認為,您可以考慮制作類似於GADBannerView
單例的東西,而不是將子視圖添加到UITabBar,然后可以將其添加到UITabBarController
包含的ViewControllers
中。
因此,您可以很容易地設置一個單例(這里還有另一個StackOverflow問題,該問題討論如何對AdMob廣告執行此操作,並使其與AdWhirl一起使用應該很簡單)。
然后只需將一些ViewControllers
添加到您的UITabBarController
,例如:
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];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.