Search code examples
iosobjective-cseguesplash-screeninterstitial

Interstitial between SplashScreen and HomePage (Segue not working, blackscreen)


I know this is a frequently asked question, but I didn't find my answer after reading all the similar questions.

So here is my issue, I am integrating Ads in my application, and basically what I'm trying to achieve is to show an Interstitial during the SplashScreen, just before accessing the HomePage.

For now this is what I have :

- Launch the App -> Display the SplashScreen -> Display the HomePage and right after Display the Interstitial.

What I want :

- Launch the App -> Display the SplashScreen -> Display the Interstitial and when the Ad is closed, Display the HomePage.

I can display the Interstitial during the SplashScreen, but my performSegueWithIdentifier is not working, either it shows me a Blackscreen or the App blocks on the Splasenter code herehScreen.

To illustrate what I'm saying, here is some code of my SplashScreen ViewController.

- (void)loadHomeView
{
    if(_isDataLoaded && !_isInterstitialDisplay && [MFPreferencesUtils firstLaunch] != nil)
    {
        [self createSplashInterstitial];
        //I also tried with performSelectorOnMainThread
    }
}

The Interstitial Delegate :

-(void)adsAdapterInterstitialDisappear:(Adapter *)adsAdapter{
   _isInterstitialDisplay = NO;
   [self displayHome];
}

And the displayHome method, called when the user closes the Ad :

-(void) displayHome
{
    dispatch_async(dispatch_get_main_queue(), ^{
       [self performSegueWithIdentifier:@"SplashscreenDisappearToHome" sender:self];
    });
}

I think this is a simple behaviour, maybe I don't really understand how Segues work, but if I don't call the Interstitial and instead, directly call my HomePage it is working.

- (void)loadHomeView
{
    if(_isDataLoaded && !_isInterstitialDisplay && [MFPreferencesUtils firstLaunch] != nil)
    {
        [self performSelectorOnMainThread:@selector(displayHome) withObject:nil
    waitUntilDone:NO];
    }
}

Thank you for reading, let me know if you have some advices.


Solution

  • Problem solved, I was able to fix it by calling my method in viewDidAppear. This was a call to performSegue when my View wasn't loaded yet because of the Interstitial.