1
votes

i'm working on a ios app that is so structured:

mainNavigation(navigation controller for mainapp-login)->tabBarController(3 tab bar item)->NavigationController(navigation contronoller for every tab bar item).

I want add admob in the top of my app(in the top of my navigation bar...). In my viewDidLoad of a tab bar item, i did this:

- (void)viewDidLoad
{
    [super viewDidLoad];

    //bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
    bannerView_ = [[GADBannerView alloc]
                   initWithFrame:CGRectMake(0.0,
                                            70.0 -
                                            GAD_SIZE_320x50.height,
                                            GAD_SIZE_320x50.width,
                                            GAD_SIZE_320x50.height)];
    // Specify the ad's "unit identifier". This is your AdMob Publisher ID.
    bannerView_.adUnitID = @"ID";

    bannerView_.rootViewController = self;
    [self.navigationController.view addSubview:bannerView_];


    [bannerView_ loadRequest:[GADRequest request]];

}

The banner, hide the navigation bar, like so: http://cl.ly/image/3C2S0m040O2h Instead if i don't use:

bannerView_ = [[GADBannerView alloc]
                   initWithFrame:CGRectMake(0.0,
                                            70.0 -
                                            GAD_SIZE_320x50.height,
                                            GAD_SIZE_320x50.width,
                                            GAD_SIZE_320x50.height)];

But use:

bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];

Look so: http://cl.ly/image/203v1C2W1b2P Instead i want that banner is showed in top, and all content(also the navigation bar)...go below the banner. How i can do ? Thanks, and sorry for my bad english.

2

2 Answers

0
votes

NavigationBar must be on the top, you can't change it position .

Hide default navigationBar

[self.navigationController setNavigationBarHidden:YES];

Then create faked NavigationBar(subclass of UIView) and place it under bannerView. In this case you need to add custom button and push and pop inside it's action.

0
votes
    [self.navigationController setToolbarHidden:NO];
    bannerAdmob = [[GADBannerView alloc]init];
    [bannerAdmob setDelegate:self];

    [bannerAdmob setFrame:adFrame];
    bannerAdmob.adUnitID =@"ca-app-pub-0243484158988577/5535857795";

    bannerAdmob.rootViewController = self;//self.viewController;
    [self.navigationController.view addSubview:bannerAdmob];

self.navigationController.view addSubview:bannerAdmob