簡體   English   中英

從xib切換到情節提要中的場景而不是主場景

[英]Switch to a scene in storyboard from xib instead of main scene

我正在嘗試實現一個包含主登錄頁面(在Storyboard中實現)的應用程序,該頁面將用戶定向到UIWebView(在xib中實現)。 登錄成功后,我希望該應用程序從xib返回到特定場景(通過Segue連接),但會返回到主場景。

我從以下鏈接獲得了幫助,但是我仍然遇到相同的問題: 如何從視圖控制器加載情節 提要中的場景,以及如何從Xib或帶有情節提要的另一個場景中添加子視圖

我的主View Controller如下所示:

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

我嘗試了很多不同的事情(在這里的代碼中有注釋),但是它要么導致應用程序崩潰,要么返回主登錄屏幕。

我想念什么?

任何幫助表示贊賞:)

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

“ Check2”應該是您的視圖控制器。 那就是我在應用程序中所做的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM