2

AdMob を統合して、有料の iPhone アプリを無料アプリに変換しています

統合を簡素化するために、AdMobView を AppDelegate に追加しています。

画面の下部に広告が表示されているため、これはすべて正常に機能します。残念ながら、以前は下部に表示されていたコンテンツが隠れてしまいます。これは、navigationController にプッシュされる後続のビューにも当てはまります。他のすべてのボタンとビューを表示しながら、Interface Builder でコンテンツをまとめて「押しつぶし」、下部の広告ビューに合わせる方法はありますか?

以下は、adMob を統合した AppDelegate コードのサブセットです。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
// Override point for customization after application launch.   
MyViewController *viewController = [[MyViewController alloc] initWithNibName:nil bundle:nil];

navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
[viewController release];

[window addSubview:navigationController.view];

[window makeKeyAndVisible];

// Request an ad
adMobAd = [AdMobView requestAdWithDelegate:self]; // start a new ad request
[adMobAd retain]; // this will be released when it loads (or fails to load)

    return YES;
}

- (UIViewController *)currentViewControllerForAd:(AdMobView *)adView {
    return navigationController;
}

// Sent when an ad request loaded an ad; this is a good opportunity to attach
// the ad view to the hierachy.
- (void)didReceiveAd:(AdMobView *)adView {
    // get the view frame
    CGRect frame = self.window.frame;

    // put the ad at the bottom of the screen
    adMobAd.frame = CGRectMake(0, frame.size.height - 48, frame.size.width, 48);

    [navigationController.view addSubview:adMobAd];
}
4

1 に答える 1

0

adMobAd がコンテンツをブロックしないように、navigationController.view.frame のサイズを変更できます。

基本的に、これを didReceiveAd 呼び出しの最後に追加します。

CGRect navFrame = navigationController.view.frame;
navFrame.height -= 48;
navigationController.view.frame = navFrame;
于 2010-11-06T02:17:22.643 に答える