x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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!

Product Version: UE 4.9
Tags:
more ▼

asked Oct 23 '15 at 05:28 PM in Using UE4

avatar image

Superflare
130 6 7 14

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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

more ▼

answered Oct 24 '15 at 12:18 PM

avatar image

Superflare
130 6 7 14

avatar image lwg Jul 12 '17 at 03:01 PM

what mistake?Black screen while hiding a view controller

avatar image Superflare Jul 12 '17 at 06:50 PM

Hello lwg. 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?

avatar image lwg Jul 13 '17 at 01:24 AM

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

avatar image lwg Jul 13 '17 at 07:25 AM

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

avatar image Superflare Jul 13 '17 at 08:25 AM

Hello lwg, 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

I hope that this solves your problem. :)

avatar image lwg Jul 13 '17 at 09:40 AM

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

avatar image lwg Jul 13 '17 at 09:39 AM
(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question