简体   繁体   English

将ADBannerView移出屏幕吗?

[英]Move ADBannerView off screen?

Yes, I've seen the other question and they are of no help. 是的,我看到了另一个问题,它们没有帮助。 So I want to move the iAD banner off of my view. 因此,我想将iAD标语移出我的视线。 It's on the iphone, at the top of the screen on portrait view. 它位于iPhone上的人像视图屏幕顶部。 Here is my code. 这是我的代码。 Where am I going wrong here? 我在哪里错了?

//Move the banner off the screen.
- (void)moveBannerViewOffScreen
{
   if (self.bannerView.isHidden == NO)
   {
       [UIView beginAnimations:@"animateAdBannerOff" context:NULL];
       bannerView.frame = CGRectOffset(bannerView.frame, 0, bannerView.frame.size.height);
       [UIView commitAnimations];
       self.bannerView.hidden = YES;
   }    
}

//Move the banner on the screen.
- (void)moveBannerOnScreen
{
   if (self.bannerView.isHidden ==YES)
   {
       [UIView beginAnimations:@"animateAdBannerOn" context:NULL];
       bannerView.frame = CGRectOffset(bannerView.frame, 0, -bannerView.frame.size.height);
       [UIView commitAnimations];
       self.bannerView.hidden = NO;
   }
}

Better you can change code in "moveBannerViewOffScreen" for iphone like this 更好的是,您可以像这样在iPhone的“ moveBannerViewOffScreen”中更改代码

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:bannerView cache:YES];
bannerView.frame = cgRectMake(0,-50,50,320);
[UIView commitAnimations];

in"moveBannerViewOnScreen" 在“ moveBannerViewOnScreen”中

 [UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:bannerView cache:YES];
bannerView.frame = cgRectMake(0,0,50,320);
[UIView commitAnimations];

You shouldn't need the hiding related code. 您不需要隐藏相关的代码。 Also your code will move the banner view up further each time or down further each time because you applying an offset incrementally. 另外,由于您递增地应用偏移,因此代码每次都会将横幅视图每次向上或向下移动。 It is better for you to manually set the frame each time: 最好每次都手动设置框架:

//Offscreen frame
bannerView.frame = CGRectMake(0, -bannerView.frame.size.height, bannerView.frame.size.width, bannerView.frame.size.height);

//Onscreen frame
bannerView.frame = CGRectMake(0, 0, bannerView.frame.size.width, bannerView.frame.size.height); 

另一个简单的答案:[myBannerView1 setAlpha:0];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM