The error "It is assumed that there will be a root view controller in application windows" (iOS)

I created an empty application project for the iPhone and would like to show full-screen ads during the launch of the application.

I tried installing the ad following this guide: https://github.com/mopub/mopub-ios-sdk/wiki/Interstitial-Integration-For-iOS

What I did in the end:

In ViewController.h

In ViewController.m

In fact, all codes are simply copied from the previous link.

However, when the application starts, an error message appears:

It is expected that the root controller will be installed in the application windows at the end of the application launch

I think this error is probably related to the loadView method, because if I remove the loadView method, the error will disappear.

, , , loadView .

? .

+4
4

, , :

#import "ViewController.h" 

AppDelegate.m

AppDelegate.m : didFinishLaunchingWithOptions: , .

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // ... Other code

    // Override point for customization after application launch.
    ViewController *viewController = [[ViewController alloc] init];

    self.window.rootViewController = viewController;
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;
}
+7
UIViewController *vc = [[UIViewController alloc] init];

 [vc.view addSubview:self.tab_controller.view];

 [self.window setRootViewController:vc];

UIViewController *vc = [[UIViewController alloc] init];

 [vc.view addSubview:yourClass.view];

 [self.window setRootViewController:vc];
+2

, :

( return) didFinishLaunchingWithOptions

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
        return YES;
}

In the project settings → General, select the storyboard as the main interface

+1
source

Attached snapshot to help you enter image description here

On the right side of the check, there is one parameter in the attribute inspector that asks you to install a “rootView controller”

0
source

All Articles