Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation bar moves when AdMob Interstital showed

When I show Interstital Ad status bar fades away and Navigation Bar moves up. All content under navigation bar moves up to. When I close the ad everything moves down. It looks really strange and glitchy.

I'm using Navigation Controller in storyboard with Show Navigation Bar property on.

Code to show Interstital Ad in AppDelegate.m file:

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

Basically, I need everything to stay in place without moving when I present Interstital Ad.

like image 965
user1561346 Avatar asked Nov 08 '15 17:11

user1561346


1 Answers

Why not try the following:

In the StoryBoard:

  1. Add a UIVisualEffectView with Blur over your existing view hierarchy (or even outside of it)
  2. Load the AdMob into another new view on top of the blurred one or within the view above
  3. Manage the presentation from your view controller by the loading of the ad within a custom view
  4. Use auto layout animation to present the custom view on screen (maybe as a popover )

OR

Check out the UICatalog Sample from Apple. They provide an example of presenting a search display controller over the navigation bar.

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)
    }
}
like image 70
Tommie C. Avatar answered Sep 25 '22 18:09

Tommie C.