Xcode 在场景中隐藏景观iAd横幅

Xcode 在场景中隐藏景观iAd横幅,xcode,sprite-kit,banner,iad,skscene,Xcode,Sprite Kit,Banner,Iad,Skscene,我有一个名为ViewController的视图控制器,其中我有两种方法,hideAd和showAd: // Method is called when the iAd is loaded. -(void)showAd:(ADBannerView *)banner { // Creates animation. [UIView beginAnimations:nil context:nil]; // Sets the duration of the animation to 1. [UIVie

我有一个名为
ViewController
的视图控制器,其中我有两种方法,
hideAd
showAd:

// Method is called when the iAd is loaded.
-(void)showAd:(ADBannerView *)banner {

// Creates animation.
[UIView beginAnimations:nil context:nil];

// Sets the duration of the animation to 1.
[UIView setAnimationDuration:1];

// Sets the alpha to 1.
// We do this because we are going to have it set to 0 to start and setting it to 1 will cause the iAd to fade into view.
[banner setAlpha:1];

//  Performs animation.
[UIView commitAnimations];
}

//方法在iAd加载失败时调用

-(void)hideAd:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {

// Creates animation.
[UIView beginAnimations:nil context:nil];

// Sets the duration of the animation to 1.
[UIView setAnimationDuration:1];

// Sets the alpha to 0.
// We do this because we are going to have it set to 1 to start and setting it to 0 will cause the iAd to fade out of view.
[banner setAlpha:0];

//  Performs animation.
[UIView commitAnimations];
}


我希望能够从我的skscenes调用这些方法,其中两个调用了
startview
gameview
。我尝试实现此解决方案:,但
setDelegate
对我不起作用。我可以用什么方式隐藏和显示我的条幅
iads

移动alpha的位置,而不是链接alpha

-(void)showBannerView
{
    if (_adBannerViewIsVisible)
    {
        return;
    }


    if (_adBannerView)
    {
        _adBannerViewIsVisible = true;

        CGRect frame = _adBannerView.frame;

        if(app_dsp.isBannerOnTop)
        {
            frame.origin.x = 0.0f;
            frame.origin.y = -_adBannerView.frame.size.height;

        }
        else
        {
            frame.origin.x = 0.0f;
            frame.origin.y = self.size.height;// - _adBannerView.frame.size.height;
        }


        _adBannerView.frame = frame;

        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.5];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];


        if(app_dsp.isBannerOnTop)
        {
            frame.origin.x = 0.0f;
            frame.origin.y = 0.0f;
        }
        else
        {
            frame.origin.x = 0.0f;
            frame.origin.y = self.size.height - _adBannerView.frame.size.height;
        }

        _adBannerView.frame = frame;

        [UIView commitAnimations];
    }

}



-(void)hideBannerView
{
    if (!_adBannerViewIsVisible)
    {
        return;
    }

    if (_adBannerView)
    {
        _adBannerViewIsVisible = false;


        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.5];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];

        CGRect frame = _adBannerView.frame;

        if(app_dsp.isBannerOnTop)
        {
            frame.origin.x = 0.0f;
            frame.origin.y = -_adBannerView.frame.size.height ;
        }
        else
        {
            frame.origin.x = 0.0f;
            frame.origin.y = self.size.height ;
        }

        _adBannerView.frame = frame;

        [UIView commitAnimations];
    }

}

将此添加到我的viewcontroller.h是否正确?{-(void)hideBannerView;-(void)showBannerView;@property(强,非原子)IBOutlet ADBannerView*ADBannerView;}还有什么是add_dsp?我在哪里制作Adbannerviewissible BOOL?它还告诉我。大小不是viewcontroller的属性。删除app_dsp,你的横幅在顶部还是底部?若为顶部,则将内容保留在if循环内;若为底部,则使用else块。您可以在同一个类中使用bool…参见此示例