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 6208117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:45:08+00:00 2026-05-24T05:45:08+00:00

I have been working three days straight to try and integrate ads into my

  • 0

I have been working three days straight to try and integrate ads into my iPhone game. I chose mobfox and it’s been going well except a minor detail that is directly linked to my less than appropriate level of Objective-C skills.

I have everything working except that the ads get’s obscured by a UI element. So I want to bring the ads to the front and googled around and managed to figure out this:

[self.view bringSubviewToFront:bannerView];

However, that only works once as the code is in (void)viewDidLoad. I then tried to use the same code in other places of my code, in the UI init etc but I then get an error that the bannerView is not declared. I pretty much understand what xcode is telling me but I don’t have the skills to simply declare it and be done, I don’t know how to so I ask if you can help me?

All I want to do is to bring my bannerView to front at will from anywhere in the code.
Can you help me?

Best regards
Marcus

Below is the mobfox code

The following is in viewDidLoad

// MOBFOX Starts
    // create the banner view just outside of the visible area
    MobFoxBannerView *bannerView = [[MobFoxBannerView alloc] initWithFrame:
                                    CGRectMake(-800, self.view.bounds.size.height - 240, 320, 50)];
    bannerView.delegate = self;  // triggers ad loading
    //bannerView.backgroundColor = [UIColor darkGrayColor]; // fill horizontally
    bannerView.transform = CGAffineTransformMakeRotation(M_PI / 2.0); //MARCUS haxx
    //bannerView.refreshAnimation = UIViewAnimationTransitionCurlDown;
    [self.view addSubview:bannerView];
    [self.view bringSubviewToFront:bannerView];
    NSLog(@"MobFox: Ad initated and placed offscreen");

    //

This is directly after viewDidLoad

    //MOBFOX STARTS HERE
#pragma mark MobFox Delegate

- (NSString *)publisherIdForMobFoxBannerView:(MobFoxBannerView *)banner
{
    return kMyMobFoxPublisherId; 
}

- (void)mobfoxBannerViewDidLoadMobFoxAd:(MobFoxBannerView *)banner
{
    NSLog(@"MobFox: did load ad and placed on screen");

    // animate banner into view
    //[UIView beginAnimations:@"MobFox" context:nil];
    //[UIView setAnimationDuration:1];
    banner.frame = CGRectMake(135, 140, 320, 50);
    [UIView commitAnimations];


}

- (void)mobfoxBannerView:(MobFoxBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
    NSLog(@"MobFox: did fail to load ad: %@", [error localizedDescription]);

    // animate banner outside view
    //[UIView beginAnimations:@"MobFox" context:nil];
    //[UIView setAnimationDuration:1];
    banner.frame = CGRectMake(-800, self.view.bounds.size.height - 240, 320, 50);
    [UIView commitAnimations];
}


//MOBFOX ENDS HERE

Example of where I would like to call bringSubViewToFront:bannerView but can’t

-(void) settitleMenuToFront {   

[self.view bringSubviewToFront:titleScreenImg];
[self.view bringSubviewToFront:highScoreTable];
[self.view bringSubviewToFront:ContinueButton];
[self.view bringSubviewToFront:highscoreButton];
[self.view bringSubviewToFront:newgameButton];
if (loadingScreen.alpha > 1) {
    [self.view bringSubviewToFront:loadingScreen];
}

}

  • 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-24T05:45:09+00:00Added an answer on May 24, 2026 at 5:45 am

    You need to add an instance variable, or ivar. The most straightforward way to do this is by adding a property and letting the compiler add the variable (the ivar) to store the property value.

    In your header file, add a line:

    @property (nonatomic, retain) MobFoxBannerView *bannerView;
    

    In your implementation, add this line near the top:

    @synthesize bannerView;
    

    Release it in -dealloc

    -(void)dealloc {
        // ...
        [bannerView release];
    }
    

    Then when you create the view, set the property:

    self.bannerView = [[[MobFoxBannerView alloc] initWithFrame:
                          CGRectMake(-800, self.view.bounds.size.height - 240, 320, 50)]
                       autorelease];
    

    You can then refer to self.bannerView anywhere in the rest of your code.

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

Sidebar

Related Questions

Here's a tricky iPhone problem I've been working on. I have three UIScrollViews on
I have been working on a project for a few days now and have
I've been working non-stop for the last three days on a completely managed interface
I have been working on this frustrating bug for a few days now and
I have been working with WPF all of 2 days, coming from ASP.NET so
I have been working on this problem for close to 4 days now. I
I have a project that I have been working on for a few days
Okay guys I have a database I have been working on for days now.
For the last few days I have been thinking and working on a website.
I have been working for a couple days trying to figure out how to

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.