【问题标题】:Switch to a scene in storyboard from xib instead of main scene从 xib 而不是主场景切换到情节提要中的场景
【发布时间】:2013-11-04 12:16:27
【问题描述】:

我正在尝试实现一个包含主登录页面(在 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];
}

我尝试了很多不同的方法(在此处的代码中进行了注释),但它要么导致应用程序崩溃,要么返回主登录屏幕。

我错过了什么?

任何帮助表示赞赏:)

【问题讨论】:

    标签: ios objective-c uiwebview storyboard xib


    【解决方案1】:
    Check2 *viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"check2"];
        [self.navigationController pushViewController:viewController animated:YES];
    

    'Check2' 应该是您的视图控制器。 这就是我在我的应用中所做的。

    【讨论】:

      猜你喜欢
      • 2012-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多