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

  • Home
  • SEARCH
  • 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 8034423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:00:30+00:00 2026-06-05T02:00:30+00:00

#pragma mark – iAd method. /*Starts:iAd*/ -(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { Class cls = NSClassFromString(@ADBannerView); if(cls!=nil)

  • 0
#pragma mark - iAd method.


/*Starts:iAd*/

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{

    Class cls = NSClassFromString(@"ADBannerView");
    if(cls!=nil)
    {
        [self layoutForCurrentOrientation:YES];
    }   

}

-(void)createADBannerView
{

    NSString *contentSize = UIInterfaceOrientationIsPortrait(self.interfaceOrientation) ? ADBannerContentSizeIdentifierPortrait : ADBannerContentSizeIdentifierPortrait;

    CGRect frame;
    frame.size = [ADBannerView sizeFromBannerContentSizeIdentifier:contentSize];
    frame.origin = CGPointMake(0.0, CGRectGetMaxY(self.view.bounds));


    // Now to create and configure the banner view
    ADBannerView *bannerView = [[ADBannerView alloc] initWithFrame:frame];
    // Set the delegate to self, so that we are notified of ad responses.
    bannerView.delegate = self;
    // Set the autoresizing mask so that the banner is pinned to the bottom
    bannerView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleTopMargin;
    bannerView.requiredContentSizeIdentifiers = [NSSet setWithObjects:ADBannerContentSizeIdentifierPortrait, ADBannerContentSizeIdentifierPortrait, nil];

    // At this point the ad banner is now be visible and looking for an ad.
    [self.view addSubview:bannerView];
    self.banner = bannerView;
    [bannerView release];
}


-(void)layoutForCurrentOrientation:(BOOL)animated
{

    CGFloat animationDuration = animated ? 0.2 : 0.0;
    // by default content consumes the entire view area
    CGRect contentFrame = self.view.bounds;
    CGPoint bannerOrigin = CGPointMake(CGRectGetMinX(contentFrame), CGRectGetMaxY(contentFrame));
    CGFloat bannerHeight = 0.0;

    banner.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
    bannerHeight = 55.0;

    if(banner.bannerLoaded)
    {
        contentFrame.size.height -= bannerHeight;
        bannerOrigin.y -= bannerHeight;
    }
    else
    {
        bannerOrigin.y += bannerHeight;
    }

    // And finally animate the changes, running layout for the content view if required.

    NSLog(@"[UIApplication sharedApplication].statusBarOrientation = %d",[UIApplication sharedApplication].statusBarOrientation);



    [UIView animateWithDuration:animationDuration
                     animations:^{
                         contentView.frame = contentFrame;
                         [contentView layoutIfNeeded];

                         banner.frame = CGRectMake(0,361, banner.frame.size.width, banner.frame.size.height);   
                     }];
}


/*Ends:iAd*/

/*Starts:Added By:CP.Date:26-Dec-2010.
 AdMob methods*/

#pragma mark - AdMobDelegate methods

-(NSString *) publisherIdForAd:(AdMobView *)adView

{

    return @"a14f91029b8c719"; // this should be prefilled; if not, get it from www.admob.com
}

-(UIViewController *) currentViewControllerForAd:(AdMobView *)adView
{

    return self;
}

-(UIColor *)adBackgroundColorForAd:(AdMobView *)adView 
{

    return [UIColor colorWithRed:0 green:0 blue:0 alpha:1]; // this should be prefilled; if not, provide a UIColor
}

-(UIColor *)primaryTextColorForAd:(AdMobView *)adView 
{

    return [UIColor colorWithRed:1 green:1 blue:1 alpha:1]; // this should be prefilled; if not, provide a UIColor
}

-(UIColor *)secondaryTextColorForAd:(AdMobView *)adView 
{

    return [UIColor colorWithRed:1 green:1 blue:1 alpha:1]; // this should be prefilled; if not, provide a UIColor
}

-(void) didReceiveAd:(AdMobView *)adView
{

    adMobAd.frame = CGRectMake(0,361,320,55);

    //adMobAd = [AdMobView requestAdOfSize:ADMOB_SIZE_748x110 withDelegate:self];
    [self.view addSubview:adMobAd];
}

// Sent when an ad request failed to load an ad

-(void)didFailToReceiveAd:(AdMobView *)adView 
{

    Class cls = NSClassFromString(@"ADBannerView");
    if(cls!=nil)
    {
        if(banner == nil)
        {
            [self createADBannerView];
        }
        [self layoutForCurrentOrientation:NO];
    }   

    [adMobAd removeFromSuperview];  // Not necessary since never added to a view, but doesn't hurt and is good practice
    [adMobAd release];
    adMobAd = nil;
    // we could start a new ad request here, but in the interests of the user's battery life, let's not
}

/*Ends:Added By:CP.Date:26-Dec-2010.
 AdMob methods*/
  • 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-06-05T02:00:33+00:00Added an answer on June 5, 2026 at 2:00 am

    first of all be clear about iad or admob , that are two different plateform for displaing adv in your app.
    i think you are try to integrate admob adv. you need to following steps for it.

    http://www.edumobile.org/iphone/iphone-programming-tutorials/how-to-admob-integrate-in-your-application-in-iphone/

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

Sidebar

Related Questions

I have the following ADBannerViewDelegate implementations: #pragma mark ADBannerViewDelegate Methods - (void)bannerViewDidLoadAd:(ADBannerView *)banner {
#pragma mark SA_OAuthTwitterControllerDelegate - (void) OAuthTwitterController: (SA_OAuthTwitterController *) controller authenticatedWithUsername: (NSString *) username {
#pragma mark - #pragma mark Fetch loans from internet -(void)loadData { self.responseData = [NSMutableData
I'm capturing images using this code #pragma mark - image capture // Create and
update: player can be opened when user clicks on the webview #pragma mark -
I'm arranging my methods into groups using #pragma mark in implementation. But sometimes, the
I'm pretty sure this isn't a duplicate. Do you use #pragma mark? I've seen
I'm using #pragma mark - Description all over my source code to use with
I was following the code here #pragma mark UITextFieldDelegate - (BOOL)textFieldShouldReturn:(UITextField *)textField { [textField
I'm trying to find where I can see the result of #pragma mark s

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.