当我显示插页式广告时,状态栏逐渐消失,导航栏向上移动。导航栏下所有内容上移。当我关闭广告时,一切都会向下移动。它看起来非常奇怪和故障。
我在 Storyboard 中使用 Navigation Controller 并启用了 Show Navigation Bar
属性。
在 AppDelegate.m
文件中显示插页式广告的代码:
[self.interstitialAd presentFromRootViewController:self.window.rootViewController];
基本上,当我展示插页式广告时,我需要所有东西都留在原地不动。
最佳答案
为什么不尝试以下方法:
在 Storyboard 中:
- 在您现有的 View 层次结构上添加一个带有模糊效果的 UIVisualEffectView (甚至在它之外)
- 将 AdMob 加载到模糊 View 之上的另一个新 View 中,或者 在上面的 View 中
- 通过加载 自定义 View 中的广告
- 使用自动布局动画在屏幕上呈现自定义 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/