ios - iAd 横幅位置未更新

标签 ios swift sprite-kit iad xcode6.3.2

我目前正在将 iAd 横幅添加到我的 SpriteKit 游戏中,我已经成功地展示了广告。但是,当我通过将横幅从底部推出来移除横幅时,它不会移动,即使它与让它出现的代码完全相反。

这是从通知观察者调用的函数:

func hideBannerAd(notification:NSNotification)
{
    if bannerAdVisible == true
    {
        println(bannerAd.frame);

        UIView.beginAnimations("hideAd", context: nil);
        bannerAd.frame = CGRectOffset(bannerAd.frame, 0, bannerAd.frame.size.height);
        println(bannerAd.frame);
        UIView.commitAnimations()
        bannerAdVisible = false
        bannerAd.cancelBannerViewAction()
    }
}

2 个 println 语句产生以下结果:

(0.0, 1024.0, 768.0, 66.0)

(0.0, 1090.0, 768.0, 66.0)

所以横幅的位置正在改变,但它没有显示在屏幕上。

如果您知道问题所在,我将不胜感激。

编辑 我将补充一点,hideBannerAd 和与广告有关的所有代码都在 GamveViewController 中。

最佳答案

问题解决了!

在@aramusss 评论的帮助下,我发现我正在调用函数以在 viewWIllLayoutSubViews 函数中显示横幅,因此我将其移至 viewDidLoad 函数现在可以使用了!

谢谢大家的帮助!

关于ios - iAd 横幅位置未更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30986725/

相关文章:

ios - 与转换它的 SKSpriteNode 一起淡化阴影

ios - Swift - 为多个按钮分配标题

ios - 实现可以在 Bolts Framework 中取消的任务 (BFTask)

ios - 以编程方式添加的约束不起作用

ios - 如何使用 SwiftUI 创建带有刻度线的 slider ?

ios - 适用于 Mac 的 Visual Studio : Guid should contain 32 digits with 4 dashes (xxxx. ..)

ios - 根据单元格索引路径向 TableView 单元格元素添加渐变层

ios - 添加阅读更多标签和扩展 UITableViewCell

arrays - swift 2.0 - 错误 : Immutable value of type '[String]' only has mutating members named 'append'

ios - SpriteKit 重力混淆