Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6759661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:58:21+00:00 2026-05-26T13:58:21+00:00

When my application launches, iAd refuses to load an ad on the first screen.

  • 0

When my application launches, iAd refuses to load an ad on the first screen. No error message, nothing. If I switch screens (going to another screen), it starts getting ads and serving them up, even when I go back to the first screen.

I am using a single iAd instance that is in the ApplicationDelegate. I am attempting to link in the iAdBanner in viewDidAppear, and unlink in viewWillDisappear.

The viewDidAppear method:

- (void)viewDidAppear:(BOOL)animated
{
    NSLog(@"view did appear");
    [super viewDidAppear:animated];

    ADBannerView *adBanner = SharedAdBannerView;

    adBanner.requiredContentSizeIdentifiers = (&ADBannerContentSizeIdentifierPortrait != nil) ?
    [NSSet setWithObjects:ADBannerContentSizeIdentifierPortrait, ADBannerContentSizeIdentifierLandscape, nil] : 
    [NSSet setWithObjects:ADBannerContentSizeIdentifier320x50, ADBannerContentSizeIdentifier480x32, nil];


    [self.view addSubview:adBanner];
    // set the delegate to self, so that we are notified of ad responses
    [adBanner setDelegate:self];
    isAdShown = [adBanner isBannerLoaded];
    [self layoutForCurrentOrientation:animated];
}

The layout method:

- (void)layoutForCurrentOrientation:(BOOL)animated
{
    //TODO: this only handles bottom-located elements


    ADBannerView *adBanner = SharedAdBannerView;

    CGFloat animationDuration = animated ? 0.2f : 0.0f;
    // by default content consumes the entire view area
    CGRect contentFrame = contentView.bounds;
    CGRect owningViewFrame = [self view].bounds;
    // the banner still needs to be adjusted further, but this is a reasonable starting point
    // the y value will need to be adjusted by the banner height to get the final position
    CGPoint bannerOrigin = CGPointMake(CGRectGetMinX(owningViewFrame), CGRectGetMaxY(owningViewFrame));
    CGFloat bannerHeight = 0.0f;

    // First, setup the banner's content size and adjustment based on the current orientation
    if(UIInterfaceOrientationIsLandscape(self.interfaceOrientation))
        adBanner.currentContentSizeIdentifier = (&ADBannerContentSizeIdentifierLandscape != nil) ? ADBannerContentSizeIdentifierLandscape : ADBannerContentSizeIdentifier480x32;
    else
        adBanner.currentContentSizeIdentifier = (&ADBannerContentSizeIdentifierPortrait != nil) ? ADBannerContentSizeIdentifierPortrait : ADBannerContentSizeIdentifier320x50; 
    bannerHeight = adBanner.bounds.size.height;

    // Depending on if the banner has been loaded, we adjust the content frame and banner location
    // to accomodate the ad being on or off screen.
    // This layout is for an ad at the bottom of the view.
    if (isAdShown)
    {
        NSLog(@"Banner is loaded");
        contentFrame.size.height = owningViewFrame.size.height - bannerHeight;
        bannerOrigin.y -= bannerHeight;
    }
    else
    {
        NSLog(@"Banner is not loaded");
        bannerOrigin.y += bannerHeight;
        contentFrame.size.height = owningViewFrame.size.height;
    }
    NSLog(@"Banner content Frame: (%f, %f), (%f, %f)", bannerOrigin.x, bannerOrigin.y, contentFrame.size.width, contentFrame.size.height);
    // And finally animate the changes, running layout for the content view if required.
    [UIView animateWithDuration:animationDuration
                     animations:^{
                         contentView.frame = contentFrame;
                         [contentView layoutIfNeeded];
                         adBanner.frame = CGRectMake(bannerOrigin.x, bannerOrigin.y, adBanner.frame.size.width, adBanner.frame.size.height);
                     }];
}

and the viewWillDisappear method:

-(void)viewWillDisappear:(BOOL)animated
{
    NSLog(@"View will disappear");
    [super viewWillDisappear:animated];
    [self removeLinkToAdBanner:animated];
}
-(void)removeLinkToAdBanner:(BOOL)animated
{
    ADBannerView *adBanner = SharedAdBannerView;
    if ([adBanner delegate] == self) {
        adBanner.delegate = nil;
        [adBanner removeFromSuperview];
    }
}

The real frustration was this was working in the simulator before I upgraded to xcode 4. I upgraded, and all of a sudden it has stopped working. Anyone else seen behavior like this? Any ideas what I can do to fix it? The behavior occurs in the simulator on all test versions of 4.x (4.0 through 4.3).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:58:21+00:00Added an answer on May 26, 2026 at 1:58 pm

    I have encountered the same problem, and the fix is in the AppDelegate’s bannerViewDidLoadAd method. You need to call your showBanner method there in order for the ad to display initially.

    - (void)bannerViewDidLoadAd:(ADBannerView *)banner
    {
         [_currentController showBannerView:_bannerView animated:YES];
    }
    

    Please check the new iAdSuite sample codes where I took this out.

    iAdSuite Sample Code Updated 10/31/11

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java application that launches another java application. The launcher has a
I've got an application that launches an introduction flow on first run like this:
I have a c++ console application that launches another application and communicates with it
Getting this error on ALL ClickOnce application launches for a certain user. This started
I have an application that launches a webpage in the current browser when the
I have a MFC application that launches a IWebBrowser2 window. On users computers where
Okay so I want to make an application that launches other applications. However, the
It seems like a standard requirement: next time the user launches the application, open
I have an application running only on Windows and a batch file that launches
My winform application is launched by another application (the parent), I need determine the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.