0

是的,我已经看到了另一个问题,但它们没有帮助。所以我想把 iAD 横幅从我的视野中移开。它在 iPhone 上,在纵向视图的屏幕顶部。这是我的代码。我在哪里错了?

//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;
   }
}
4

3 回答 3

1

更好的是,您可以像这样为 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];

在“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];
于 2012-06-22T06:41:12.693 回答
0

您不需要隐藏相关代码。此外,您的代码每次都会将横幅视图向上或向下移动,因为您逐渐应用偏移量。最好每次手动设置框架:

//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); 
于 2012-06-22T12:48:29.140 回答
0

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

于 2013-08-12T21:22:58.070 回答