【问题标题】:Navigation bar moves when AdMob Interstital showedAdMob 插页式广告显示时导航栏移动
【发布时间】:2015-11-08 17:05:52
【问题描述】:

当我显示插页式广告时,状态栏消失并且导航栏向上移动。导航栏下的所有内容都向上移动。当我关闭广告时,一切都会下降。它看起来真的很奇怪而且有问题。

我在情节提要中使用导航控制器并启用了Show Navigation Bar 属性。

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

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

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

【问题讨论】:

  • 试试下面:UINavigationController *aNavCntrl = [[UINavigationController alloc] initWithRootViewController:self.interstitialAd]; [aNavCntrl presentFromRootViewController:self.window.rootViewController];
  • @SharmaVishal,self.interstitialAdGADInterstitial 不是 ViewControllerUINavigationController 也没有 presentFromRootViewController 方法。也许您想更正您的评论?
  • 是的,请原谅。只是认为:)
  • 您是否在使用 Storyboard,并使用顶部和底部布局指南来放置视图?
  • @SwiftArchitect,是的,没错。

标签: ios uiview uiviewcontroller admob interstitial


【解决方案1】:

为什么不尝试以下方法:

在故事板中:

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

查看 Apple 的 UICatalog 示例。它们提供了在导航栏上显示搜索显示控制器的示例。

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)
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多