Ios 如何检测iAd是否使用;如果;陈述
我有一个代码,根据用户何时拥有iphone 4或5以及何时购买IAP删除广告来创建按钮。下面是该代码:Ios 如何检测iAd是否使用;如果;陈述,ios,if-statement,iad,Ios,If Statement,Iad,我有一个代码,根据用户何时拥有iphone 4或5以及何时购买IAP删除广告来创建按钮。下面是该代码: if ((int)[[UIScreen mainScreen] bounds].size.height == 568) { // This is iPhone 5 screen if (intvalue == 1) { //No Ads self.infoButton = [UIButton buttonWithType:UIButtonType
if ((int)[[UIScreen mainScreen] bounds].size.height == 568)
{
// This is iPhone 5 screen
if (intvalue == 1) {
//No Ads
self.infoButton = [UIButton buttonWithType:UIButtonTypeInfoDark];
self.infoButton.tintColor = [UIColor whiteColor];
self.infoButton.center = CGPointMake(289, 495);
[self.view addSubview:self.infoButton];
}
else{
//Yes Ads
self.infoButton = [UIButton buttonWithType:UIButtonTypeInfoDark];
self.infoButton.tintColor = [UIColor whiteColor];
self.infoButton.center = CGPointMake(289, 451);
[self.view addSubview:self.infoButton];
}
} else {
// This is iPhone 4/4s screen
if (intvalue == 1|) {
//No Ads
self.infoButton = [UIButton buttonWithType:UIButtonTypeInfoDark];
self.infoButton.tintColor = [UIColor whiteColor];
self.infoButton.center = CGPointMake(289, 429);
[self.view addSubview:self.infoButton];
}
else{
//Yes Ads
self.infoButton = [UIButton buttonWithType:UIButtonTypeInfoDark];
self.infoButton.tintColor = [UIColor whiteColor];
self.infoButton.center = CGPointMake(289, 400);
[self.view addSubview:self.infoButton];
}
}
然而,对我来说,当广告没有加载时,会出现一个问题。该按钮在屏幕中的位置仍然高于其应在的位置。如何检测ads是否未加载?在删除ads时将按钮放置在的位置?您需要在类中实现ADBannerViewDelegate协议 加载广告后,苹果将调用BannerViewIDLoadAD 未加载广告时,苹果将调用bannerView:didFailToReceiveAdWithError:
因此,对于临时修复,在您的代码中,我总是绘制按钮,就好像没有加载广告一样。然后,当广告加载时(在BannerViewIDLoadAD内部),向下移动按钮并显示广告。查看其委托方法:
BannerViewIDLoadAD:
?