0

I am trying to implement an app that includes a main Login page(implemented in Storyboard) which directs the user to a UIWebView (implemented in xib). When the login is successful, I expect the app to return from the xib to a particular scene (connected by Segue) but instead it returns to the main scene.

I had help from the following links however, I still have the same problem: How to load a scene in a storyboard from a view controller and Add subview from a xib or another scene with storyboard

My main View Controller looks like this:

- (IBAction)loginButton:(id)sender

{

    oAuthLoginView = [[OAuthLoginView alloc] initWithNibName:nil bundle:nil];
    [oAuthLoginView retain];

    // register to be told when the login is finished
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(loginViewDidFinish:)
                                                 name:@"loginViewDidFinish"
                                               object:oAuthLoginView];

    [self presentModalViewController:oAuthLoginView animated:YES];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
   UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];
    UINavigationController *navigationController = [self.storyboard instantiateViewControllerWithIdentifier:@"check2"];
//    SecondViewController *viewController = navigationController.viewControllers[0];
//    
//    // setup "inner" view controller
//   // viewController. = bar;
//    
//    [self presentViewController:navigationController animated:YES completion:nil];

}


-(BOOL) loginViewDidFinish:(NSNotification*)notification
{

[self performSegueWithIdentifier:@"afterLoginScreen" sender:self];

    return YES;


  // [self performSegueWithIdentifier:@"mainApp" sender:self];


    // UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    //  ProfileTabView * yourView = (ProfileTabView *)[storyboard instantiateViewControllerWithIdentifier:@"segueID"];
    //   [self.presentedViewController:yourView animated:YES completion:^{}];

    //[self switchToStoryBoard];
}

I have tried a lot of different things(commented in the code here) but it either leads to crashing the application or returns back to the main login screen.

What am I missing?

Any help appreciated :)

Community
  • 1
  • 1
Shruti Kapoor
  • 1,106
  • 2
  • 12
  • 32

1 Answers1

0
Check2 *viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"check2"];
    [self.navigationController pushViewController:viewController animated:YES];

'Check2' should be your view controller. Thats what I'm doing in my app.

Idan Moshe
  • 1,675
  • 4
  • 28
  • 65