Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 将ADBannerView移出屏幕?_Iphone_Xcode_Uiview_Adbannerview - Fatal编程技术网

Iphone 将ADBannerView移出屏幕?

Iphone 将ADBannerView移出屏幕?,iphone,xcode,uiview,adbannerview,Iphone,Xcode,Uiview,Adbannerview,是的,我看到了另一个问题,他们没有帮助。 所以我想把iAD横幅从我的视线中移开。它在iphone上,在纵向视图屏幕的顶部。这是我的密码。我哪里出了问题 //Move the banner off the screen. - (void)moveBannerViewOffScreen { if (self.bannerView.isHidden == NO) { [UIView beginAnimations:@"animateAdBannerOff" context:N

是的,我看到了另一个问题,他们没有帮助。 所以我想把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;
   }
}

你最好能像这样在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];
在“MoveBannerViewScreen”中


您不应该需要隐藏相关代码。此外,由于以增量方式应用偏移,因此代码每次都会将横幅视图进一步上移或下移。您最好每次手动设置帧:

//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]

我认为只有在加载视图或其任何委托时才能调用setFrame属性。您是否尝试使用AddSubViews加载视图,这适用于由于网络中断等原因显示广告时出现错误。您的cgRectMake应为cgRectMake。这样没有错误。谢谢你的帮助!这些数字是硬编码的。我在下面给出了一个更灵活的答案。我还解释了为什么原来的解决方案不起作用。事实上,苹果公司说要隐藏横幅,直到有广告显示。或者,如果没有广告能够显示bc的网络问题,则隐藏横幅。[好的,谢谢,我明白你的想法。这有点含糊不清,但我认为你不需要设置隐藏属性。事实上,将视图移出屏幕可能是指“你的应用程序必须隐藏横幅视图”.哦,我明白你的意思了,是的,我只是想把视图移出屏幕,而不是隐藏它。你的代码不会将横幅动画化到视图中,你能在保持“灵活性”的同时这样做吗?另外,如果应用程序进入后台,我将如何隐藏横幅?你能解释一下是什么让你的代码更灵活吗?我也想知道其他新程序员也会这么做。谢谢!
//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);