我在屏幕底部有ADBannerView的IBOutlet,当它显示白屏(无法加载广告)时我不会隐藏它。
我有这段代码,但它无效:
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
[UIView beginAnimations:@"showAd" context:nil];
CGRect adBannerViewFrame = [bannerView frame];
adBannerViewFrame.origin.x = 160;
adBannerViewFrame.origin.y = 523;
bannerView.frame = adBannerViewFrame;
[UIView commitAnimations];
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
[UIView beginAnimations:@"hideAd" context:nil];
CGRect adBannerViewFrame = [bannerView frame];
adBannerViewFrame.origin.x = 0;
adBannerViewFrame.origin.y = 0;
bannerView.frame = adBannerViewFrame;
[UIView commitAnimations];
}
你能帮助我吗,我在过去两个小时里一直在努力......:/
答案 0 :(得分:0)
你应该尝试这样的事情(这是来自现场项目)。 iAd横幅位于屏幕的底部,当它变得不可见时会下降,当它必须可见时它会回来。
_isiADBannerVisible
只是一个简单的Boolean
变量。
- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
if (_isiADBannerVisible == false) {
_isiADBannerVisible = true;
[UIView animateWithDuration:0.5f delay:0.f options:UIViewAnimationCurveEaseInOut animations:^{
[banner setFrame:CGRectOffset(banner.frame, 0.f, -50.f)];
} completion:nil];
}
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
if (_isiADBannerVisible == true) {
_isiADBannerVisible = false;
[UIView animateWithDuration:0.5f delay:0.f options:UIViewAnimationCurveEaseInOut animations:^{
[banner setFrame:CGRectOffset(banner.frame, 0.f, +50.f)];
} completion:nil];
}
}