Objective c MoPub横幅广告未出现
我想让MoPub的横幅广告出现。我已经创建了一个UIViewController,并将MoPub代码放入视图加载中,如下所示Objective c MoPub横幅广告未出现,objective-c,uiviewcontroller,mopub,Objective C,Uiviewcontroller,Mopub,我想让MoPub的横幅广告出现。我已经创建了一个UIViewController,并将MoPub代码放入视图加载中,如下所示 - (id)init { self = [super init]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional se
- (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.
}
在控制台中,我似乎得到了正确的MSG,因为
正在查找名为MPHTMLBannerCustomEvent的自定义事件类。MOPUB:
加载MoPub HTML横幅MoPub:MoPub HTML横幅未加载
但是我在模拟器的屏幕上看不到任何东西,有什么想法吗?你的
\gcViewController
是全屏视图吗?您在添加了adViewController.view
之后添加了它的子视图,因此您可能会使它变得模糊。
//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];