我是第一次整合iAds。有用。我似乎无法做到的是将它放在屏幕的底部。当我做我认为是正确的数学时,它会停止显示(或者我不会看到它),但将位置更改为硬编码值。
// Use RootViewController manage CCEAGLView
_viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
_viewController.wantsFullScreenLayout = YES;
_viewController.view = eaglView;
// Set RootViewController to window
if ([[UIDevice currentDevice].systemVersion floatValue] < 6.0)
{
// warning: addSubView doesn't work on iOS6
[window addSubview: _viewController.view];
}
else
{
// use this method on ios6
[window setRootViewController:_viewController];
}
// iAd
adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
CGRect adFrame = adView.frame;
adFrame.origin.y = adView.frame.size.height;
adView.frame = adFrame;
[_viewController.view addSubview:adView];
有效,但它显示如下:
当我尝试根据屏幕高度将位置更改为底部时 - adView高度我不再看到它。
adFrame.origin.y = _viewController.view.frame.size.height - adView.frame.size.height;
我放置了断点,看起来这应该基于高度(1024)和adView(66)的值
更新:我现在正尝试初始化指定一个矩形
adView = [[ADBannerView alloc] initWithFrame:CGRectMake(0, [[UIScreen mainScreen] bounds].size.height - adView.frame.size.height, [[UIScreen mainScreen] bounds].size.width, adView.frame.size.height)];
[adView setDelegate:self];
[_viewController.view addSubview:adView];
仍然无法正常工作,不再显示任何内容。
更新2:尝试这样做确实显示,显然不在底部
adView = [[ADBannerView alloc] initWithFrame:CGRectMake(0, 200, [[UIScreen mainScreen] bounds].size.width, 200)];
更新3:尝试这一点,确实显示,显然不在底部
adView = [[ADBannerView alloc] initWithFrame:CGRectMake(0, 200, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height)];
更新4:尝试这个,在底部工作,但我只是做了这个。将300更改为200然后没有显示。
adView = [[ADBannerView alloc] initWithFrame:CGRectMake(0, [[UIScreen mainScreen] bounds].size.height - 300, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height)];
答案 0 :(得分:0)
为什么不在创建横幅视图时直接使用initWithFrame?
我在我的应用程序中如下所示,它对我来说很好用
CGFloat adBannerHeight = 100.0f;
bannerView = [[ADBannerView alloc]initWithFrame:CGRectMake(0, [[UIScreen mainScreen] bounds].size.height - adBannerHeight,[[UIScreen mainScreen] bounds].size.width,adBannerHeight)];
[bannerView setDelegate:self];
[[self view] addSubview:bannerView];
此外,请确保您实施所有必要的委托方法