0

When debugging, viewDidLoad of LoginViewController is called, but the screen is black screen. I really don't know why..

@interface AppDelegate ()

@property (nonatomic, strong) AppCoordinator *appCoordinator;

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame: UIScreen.mainScreen.bounds];
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    LoginViewController *vc = [sb instantiateViewControllerWithIdentifier:@"LoginView"];
    
    //UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController: vc];
    self.window.rootViewController = vc;
    [self.window makeKeyAndVisible];
    
    return YES;
}

LoginViewController.m


#import "LoginViewController.h"

@implementation LoginViewController

- (void)viewDidLoad {
    NSLog(@"LoginViewController viewDidLoad");
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor redColor];
    
}


@end
8
  • If you are using a storyboard, why have this code at all? Just let the storyboard do its thing. Commented May 8, 2023 at 1:51
  • Screen conversion using the coordinator pattern is a basic step to implement with code. Commented May 8, 2023 at 2:00
  • You don’t assert on nil vc Commented May 8, 2023 at 2:01
  • That part seems to be a part that needs to be improved.. but it is not the cause of the above problem.. :( Commented May 8, 2023 at 2:03
  • 1
    If this is a modern project it will use the scene lifecycle and your code for configuring the window should be in the scene delegate, not the app delegate. Commented May 8, 2023 at 7:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.