从xib而不是主场景切换到storyboard中的场景

时间:2013-11-04 12:16:27

标签: ios objective-c uiwebview storyboard xib

我正在尝试实现一个包含主要登录页面(在Storyboard中实现)的应用程序,该页面将用户定向到UIWebView(在xib中实现)。当登录成功时,我希望应用程序从xib返回到特定场景(由Segue连接),而是返回到主场景。

我从以下链接获得了帮助,但我仍然遇到同样的问题: How to load a scene in a storyboard from a view controllerAdd subview from a xib or another scene with storyboard

我的主视图控制器如下所示:

- (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];
}

我尝试了很多不同的东西(在这里的代码中注释),但它会导致应用程序崩溃或返回主登录屏幕。

我错过了什么?

任何帮助表示赞赏:)

1 个答案:

答案 0 :(得分:0)

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

'Check2'应该是您的视图控制器。 多数民众赞成我在我的应用程序中正在做的事情。