Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 无法从xib调用情节提要_Ios_Iphone_Objective C_Uiviewcontroller_Xcode5 - Fatal编程技术网

Ios 无法从xib调用情节提要

Ios 无法从xib调用情节提要,ios,iphone,objective-c,uiviewcontroller,xcode5,Ios,Iphone,Objective C,Uiviewcontroller,Xcode5,我是iOS开发新手。我正在尝试从xib文件连接到故事板。我的xib视图控制器有一个“登录”,如果成功,应该连接到情节提要。我在谷歌上搜索了stackoverflow的解决方案,我使用的代码随处可见: UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; YourViewController * yourView = (YourViewController *)[

我是iOS开发新手。我正在尝试从xib文件连接到故事板。我的xib视图控制器有一个“登录”,如果成功,应该连接到情节提要。我在谷歌上搜索了stackoverflow的解决方案,我使用的代码随处可见:

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"];

}
我在登录成功后调用的函数中实现了这段代码。然而,故事板“故事板”从未被调用。我这样做对吗?我应该在其他地方写这段代码吗


非常感谢您的帮助:)

还有一步:演示新的视图控制器

-(void) loginViewDidFinish:(NSNotification*)notification
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];

    UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];
    ProfileTabView * yourView = (ProfileTabView *)[storyboard instantiateViewControllerWithIdentifier:@"myID"];

    // it might be better to rename 'ProfileTabView' as 'ProfileTabViewController'
    // and 'yourView' as 'profileTabVC', by convention.  Anyway ...

    [self.presentViewController:yourView animated:YES completion:^{}];
}
如果您的登录VC位于导航控制器中,则您将推送新VC:

[self.navigationController pushViewController:yourView animated:YES]; 
您需要添加“yourView”。通过push/present/add子视图将视图添加到视图层次结构中。LoginViewdFinish中的代码部分在哪里?
-(void) loginViewDidFinish:(NSNotification*)notification
{
NSNotificationCenter.defaultCenter().removeObserver(self)
let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let vc = storyboard.instantiateViewControllerWithIdentifier("ViewControllerID") as UIViewController
    self.presentViewController(vc, animated: true, completion: nil)
}