0

ViewController2 つのメソッドを持つView Controller が呼び出されhideAdshowAd:

// 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 から呼び出せるようにしたいと思います。そのうちの 2 つはstartviewgameview. このソリューションを実装しようとしました: How to show iAd on a specific SKScene and hide it on the other one、しかし私にとってはうまくいきsetDelegateません。バナーの表示と非表示を切り替えるにはどうすればよいiadsですか?

4

1 に答える 1

0

アルファをチェーンする代わりに、その位置を移動します。

-(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];
    }

}
于 2014-03-15T11:16:21.893 に答える