ios - AdMob Interstital 显示时导航栏移动

标签 ios uiview uiviewcontroller admob interstitial

当我显示插页式广告时,状态栏逐渐消失,导航栏向上移动。导航栏下所有内容上移。当我关闭广告时,一切都会向下移动。它看起来非常奇怪和故障。

我在 Storyboard 中使用 Navigation Controller 并启用了 Show Navigation Bar 属性。

AppDelegate.m 文件中显示插页式广告的代码:

[self.interstitialAd presentFromRootViewController:self.window.rootViewController];

基本上,当我展示插页式广告时,我需要所有东西都留在原地不动。

最佳答案

为什么不尝试以下方法:

在 Storyboard 中:

  1. 在您现有的 View 层次结构上添加一个带有模糊效果的 UIVisualEffectView (甚至在它之外)
  2. 将 AdMob 加载到模糊 View 之上的另一个新 View 中,或者 在上面的 View 中
  3. 通过加载 自定义 View 中的广告
  4. 使用自动布局动画在屏幕上呈现自定义 View (也许作为弹出窗口)

查看 Apple 的 UICatalog 示例。它们提供了在导航栏上呈现搜索显示 Controller 的示例。

import UIKit

class SearchPresentOverNavigationBarViewController: SearchControllerBaseViewController {
    // MARK: Properties

    // `searchController` is set when the search button is clicked.
    var searchController: UISearchController!

    // MARK: Actions

    @IBAction func searchButtonClicked(button: UIBarButtonItem) {
        // Create the search results view controller and use it for the UISearchController.
        let searchResultsController = storyboard!.instantiateViewControllerWithIdentifier(SearchResultsViewController.StoryboardConstants.identifier) as SearchResultsViewController

        // Create the search controller and make it perform the results updating.
        searchController = UISearchController(searchResultsController: searchResultsController)
        searchController.searchResultsUpdater = searchResultsController
        searchController.hidesNavigationBarDuringPresentation = false

        // Present the view controller.
        presentViewController(searchController, animated: true, completion: nil)
    }
}

关于ios - AdMob Interstital 显示时导航栏移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33596590/

相关文章:

ios - 从Unity部署到IOS模拟器出现这些Xcode提示/错误正常吗?

ios - 使用 Core Animation 和 block 发出旋转 UIView 对象的问题

ios - subview 调整大小至全屏

iphone - 将 UIViewController 代码转换为 UIView

ios5 - 带有 Storyboard的模态视图 Controller 的大小

iOS 8 当键盘出现时将 UIView 向上移动 |问题

ios - 如何对 Sprite Action 应用不同的缓动效果?

ios - Swift:更新 CollectionView 单元格图像

ios - 如何允许标签栏项目有多个 View Controller

ios - 导航 Controller 标题未显示?