2013-08-23 189 views
3

我有一个storyboard View Controller,它是我应用程序中的第一个屏幕。该应用程序的其余部分是用xib's设计的。我想从故事板的VC中的按钮继续到XIB文件。我知道如何从xib到故事板做到这一点,但这又如何呢?Segue from Storyboard to XIB

在此先感谢!

回答

13

从XIB到故事板

UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil]; 
UIViewController *initViewController = [storyBoard instantiateInitialViewController]; 

然后

[self.window setRootViewController:initViewController]; 

[self.navigationController pushViewController:initViewController animated:YES]; 

从故事板XIB

YourViewController *viewController=[[YourViewController alloc]initWithNibName:@"ViewControllerName" bundle:nil]; 

[self presentViewController:viewController animated:YES completion:nil]; 

在NavigatinController

[self.navigationController pushViewController:viewController animated:YES]; 
+0

当我尝试从故事板去厦门国际银行,我等这个错误的情况下:'FruitsMemoryGame [1588:60B] ***终止应用程序由于未捕获的异常 'NSUnknownKeyException' ,理由:'[ setValue:forUndefinedKey:]:这个类不是关键值编码兼容的关键btnHighScores.'' – Sebyddd

+2

哦,我忘了导入类。它的工作现在,非常感谢:) – Sebyddd

+0

这是由于一个破碎的IBOutlet或IBAction – yasirmturk