[英]Switch to a scene in storyboard from xib instead of main scene
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). 我正在尝试实现一个包含主登录页面(在Storyboard中实现)的应用程序,该页面将用户定向到UIWebView(在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. 登录成功后,我希望该应用程序从xib返回到特定场景(通过Segue连接),但会返回到主场景。
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 我从以下链接获得了帮助,但是我仍然遇到相同的问题: 如何从视图控制器加载情节 提要中的场景,以及如何从Xib或带有情节提要的另一个场景中添加子视图
My main View Controller looks like this: 我的主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];
}
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 :) 任何帮助表示赞赏:)
Check2 *viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"check2"];
[self.navigationController pushViewController:viewController animated:YES];
'Check2' should be your view controller. “ Check2”应该是您的视图控制器。 Thats what I'm doing in my app. 那就是我在应用程序中所做的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.