batuman
batuman

Reputation: 7304

Changing the first ViewController in iOS

Initially I developed the app with only one ViewController(called MainView). Now I'd like to add one ViewController (called LoginView)infront of MainView. I added in the AppDelegate as

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    UIStoryboard *mainStoryBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

    LoginPage *RootViewController = [mainStoryBoard instantiateViewControllerWithIdentifier:@"LoginPage"];
    [UIApplication sharedApplication].delegate.window.rootViewController = RootViewController;
    [[UIApplication sharedApplication].delegate.window makeKeyAndVisible];
    return YES;
}

It looks working, but only black screen appears. My LoginPage ViewController has the following structure. The ViewController has two buttons, one label and one text view. They don't appear and only black screen is appearer.

enter image description here

Upvotes: 0

Views: 90

Answers (1)

Igor
Igor

Reputation: 1557

Just mark your Login view controller as initial view controller in storyboard

enter image description here

Upvotes: 2

Related Questions