Question

I am trying to switch from a View (a totally normal view) to another view (also normal) programmable. Here is my already existing Code:

- (IBAction)login:(id)sender {


if([_username.text isEqualToString:name] && [_password.text isEqualToString:pw])    {


    DashboardViewController *destinationController = [[DashboardViewController alloc] init];
    [self.navigationController pushViewController:destinationController animated:YES];

}else   {
        UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Wrong Username or Password!"
                                                          message:@"Sorry."
                                                         delegate:nil
                                                cancelButtonTitle:@"Okay"
                                                otherButtonTitles:nil, nil];
        [message show];
        _password.text = nil;
    }
}

So, I want to get directed to my DashboardViewController. If I try this code, a black, empty View is shown. What is wrong with it?

Was it helpful?

Solution

I recently had the same problem! Here is the solution I used:

  UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle: nil];
DashboardViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"id"];
[self.navigationController pushViewController:viewController animated:YES];

MainStoryboard should be the name of your storyboard and id should be the View Controller ID which you can set in the storyboard.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top