3

I'm trying to get a MoPub banner ad to appear. I've created a UIViewController, and put the MoPub code into the View did load as thus..

- (id)init
{
    self = [super init];

    if (self) {
        // Custom initialization
    }
    return self;
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    // ... your other -viewDidLoad code ...
    self.adView = [[MPAdView alloc] initWithAdUnitId:@"ID HERE"
                                                 size:MOPUB_BANNER_SIZE];
    self.adView.delegate = self;
    CGRect frame = self.adView.frame;
    CGSize size = [self.adView adContentViewSize];
    frame.origin.y = [[UIScreen mainScreen] applicationFrame].size.height - size.height;
    self.adView.frame = frame;
    [self.view addSubview:self.adView];
    [self.adView loadAd];
    //[super viewDidLoad];


}

#pragma mark - <MPAdViewDelegate>
- (UIViewController *)viewControllerForPresentingModalView {
    return self;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

And in my AppDelegate I'm setting everything up like this (it's a Sparrow game)

 //setup Sparrow
    CGRect screenBounds = [UIScreen mainScreen].bounds;
    _window = [[UIWindow alloc] initWithFrame:screenBounds];

    _gcViewController = [[UIViewController alloc]init];

    _viewController = [[SPViewController alloc] init];

    [_viewController startWithRoot:[Game class] supportHighResolutions:YES doubleOnPad:YES];

    _viewController.multitouchEnabled = YES;

    [_window setRootViewController:_viewController];

    adViewController = [[AdViewController alloc]init];
    [_window addSubview:adViewController.view];

    [_window addSubview:_gcViewController.view];

    [_window makeKeyAndVisible];

And in the console I seem to be getting the correct msgs as this...

Looking for custom event class named MPHTMLBannerCustomEvent. MOPUB: Loading MoPub HTML banner MOPUB: MoPub HTML banner did load

But I can't see anything on the screen in the simulator, any ideas?

Phil
  • 2,995
  • 6
  • 40
  • 67
  • Is your `_gcViewController` view full-screen? You add its subview **after** adding the `adViewController.view`, so you might be obscuring it. – Nate Dec 07 '14 at 10:24

0 Answers0