Reputation: 92
I started using Heyzap today to integrate multiple ad networks in my iOS project. The integration went well as shown in the image below.
However, I run into problems while trying to show ads. I get warning messages saying that the ads are getting presented on top of rootviewcontroller and it's not in the view hierarchy right now.
*Warning: Attempt to present <GADInterstitialViewController: 0x14f63d9c0> on <TwentyFour.GameEntranceViewController: 0x14f5094c0> whose view is not in the window hierarchy!*
"GameEntranceViewController is my RootViewController"
How can I present ads if it's not for the rootViewController
? I have my code below, what did I do wrong?
In AppDelegate
HeyzapAds.startWithPublisherID("publisher_id")
HZInterstitialAd.fetch()
In viewDidLoad
or viewDidAppear
in a view controller which is not
RootViewController.
if HZInterstitialAd.isAvailable() {
HZInterstitialAd.show()
}
Upvotes: 0
Views: 202
Reputation: 7707
I'm an iOS engineer at Heyzap. You can create an HZShowOptions
object, set the viewController
property on it, and pass that to showWithOptions
:
let options:HZShowOptions = HZShowOptions()
options.viewController = self
HZInterstitialAd.showWithOptions(options)
Upvotes: 4