IOS Black screen while hiding a view controller

Hello!

I am trying to create a plugin for showing video ads.
I have created a view controller so that,i can use it for presenting the video ads .
Everything is working like i expected,but when i try to hide the my view controller it shows black screen.

My code looks somewhat like this…

myclass.h

#pragma once

#include "myclass.generated.h"

UCLASS(NotBlueprintable)
class Umyclass : public UObject
{
	GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable,Category = "MyClass")
static void ShowView();

UFUNCTION(BlueprintCallable,Category = "MyClass")
static void CloseView();

//If true will close myviewcontroller which was presented.
static bool ShouldClose;
};

#if PLATFORM_IOS
@interface myViewController:UIViewController
+ (myViewController*) GetSingleton;
@end
#endif

myClass.cpp

#include "myClass.h"

bool Umyclass::ShouldClose;

#if PLATFORM_IOS

@interface myViewController()<someDelegate>
@end

@implementation myViewController
 + (myViewController*) GetSingleton
 {
      static myViewController* Singleton = [[myViewController alloc] init];
      return Singleton;
}

-(void) showTheController:(UIViewController*) controller
{
      [[IOSAppDelegate GetDelegate].IOSController presentViewController : controller animated : NO completion : nil];
}

-(void) hideTheController:(UIViewController*) controller
{
    [controller dismissViewControllerAnimated : NO completion : nil];
}

//protocol method which alerts when the view controller is closed.

-(void) viewClosed()
{
   Umyclass::ShouldClose = true;
}
@end

myViewController* viewController = [[myViewController alloc] init];
#endif

void Umyclass::ShowView()
{
    ShouldClose = false;

    #if PLATFORM_IOS
      dispatch_async(dispatch_get_main_queue(), ^{
		[[myViewController GetSingleton] showTheController:viewController];
	});
    #endif
}

void Umyclass::CloseView()
{
    if(ShouldClose == true)
    {
      #if PLATFORM_IOS
      dispatch_async(dispatch_get_main_queue(), ^{
		[[myViewController GetSingleton] hideTheController:viewController];
	});
    #endif
     }
   
}

ShowView method is called when a button is clicked in the game.
It shows the controller and then after completing it’s work there is a close button available which when clicked, sends a message to the viewClosed protocol method which sets the ShouldClose variable to true.
I then call CloseView() method which then gets rid of myViewController.

But after this step the screen stays black.

Please Help!

Thank you!

Never mind,everything is working great now.
I was making a very simple mistake in blueprint.
Thank you!

what mistake?Black screen while hiding a view controller

Hello ,
Well,i don’t know what you are doing in code,so,i have no idea,what you might be doing wrong.
Can you at least see your ad,when you open the view controller?

You can visit Getsetgames github page and see how they implemented Chartboost and AdColony plugin for ios in UE and maybe you will be able to solve your problem?

I found this after i completed my plugin integration.

[GetsetGame github link][1]

I hope that this solves your problem. :slight_smile:

GitHub - getsetgames/Chartboost: A plugin for Unreal Engine 4 that integrates the Chartboost SDK.

Hello .
I don’t remember,but,i think i was opening another view controller which was doing nothing.
I was creating a plugin to add Chartboost Ads support in unreal at that time.

Are you getting black screen,when you hide your controller?

yes, i hide controller, get black screen, I use Vungle ads.

I am crazy,How to solve this problem,Please help me!

[link text][1]

202275-lwgadbplibrary.cpp.zip (3.85 KB)

it is my code, it finish video, get black screen.