【问题标题】:Hiding Landscape iAd banners in skscene在 skscene 中隐藏横向 iAd 横幅
【发布时间】:2014-03-15 06:43:03
【问题描述】:

我有一个名为 ViewController 的视图控制器,其中有两个方法,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];

}

我希望能够从我的场景中调用这些方法,其中两个称为startviewgameview。我尝试实施此解决方案:How to show iAd on a certain SKScene and hide it on the other one,但setDelegate 对我不起作用。我可以通过什么方式隐藏和显示我的横幅iads

【问题讨论】:

    标签: xcode sprite-kit banner iad skscene


    【解决方案1】:

    移动它的位置,而不是链接 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; -(无效)显示横幅视图; @property (strong, nonatomic) IBOutlet ADBannerView *adBannerView;} 还有什么是 add_dsp?我在哪里制作 adbannerviewisvissible BOOL?它还告诉我 .size 不是 viewcontroller 的属性。
    • 删除app_dsp,你的banner是在顶部还是底部?如果顶部则将内容保留在 if 循环中,如果底部则使用 else 块。您可以在同一个班级中使用 bool ...查看此示例 stackoverflow.com/questions/17815777/how-to-add-iad-in-cocos2d/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-27
    相关资源
    最近更新 更多