我是iOS开发新手。我正尝试从xib文件连接到故事板。我的xib视图控制器有一个“登录”,如果成功应该连接到故事板。我用Google搜索和搜索计算器上的解决方案,我用这个代码是无处不在给出:无法从xib调用故事板
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
YourViewController * yourView = (YourViewController *)[storyboard instantiateViewControllerWithIdentifier:@"identifier ID"];
我创造了我的故事板的标识符为好。但是,无论我尝试什么,我都不会被重定向到故事板。当登录完成后,我回到我的主视图控制器(xib)。我应该重定向到故事板。这里是我的代码看起来像在一个名为ProfileTabView.m文件:
-(void) loginViewDidFinish:(NSNotification*)notification
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];
ProfileTabView * yourView = (ProfileTabView *)[storyboard instantiateViewControllerWithIdentifier:@"myID"];
}
我已经Implemeted一个在功能这段代码中被调用一次登录成功。然而,故事板“故事板”永远不会被调用。我做对了吗?我应该在其他地方写这个代码吗?
非常感谢任何帮助:)
您需要通过任一推 “yourView” .view添加到视图层次/本/添加子视图。 loginViewDidFinish中的那部分代码在哪里? – San