我正在学习新的iOS 5.0上的Storyboard。它似乎很简单的使用和实现,但我的问题是... 我怎样才能更新旧的Xib到故事板?Xib Vs Storyboard,如何更新
例如,当没有故事板时,我开发了一些课程,并且这些课程中的某些课程附带了帮助我快速设置自定义布局的xib文件。 很显然,当我使用这种类时,我需要使用initWithNibName:bundle来实例化它,现在它已经可以使用了,我可以多次使用它,因为布局是在xib内编码的。
Now Storyboard ... Storyboard不允许从xib加载视图控制器,我没有找到一种方法来加载故事板文件在主故事板内。似乎我需要重新配置一个特定的视图控制器的布局,每次我在一个新的项目中使用它。 看来,现在我不得不重新配置我的控制器在每个使用此控制器的新应用程序中的布局,而不是使用内部布局的xib文件。
也许有一些我不明白。 任何人都可以帮助我理解使用故事板的最佳方式?
预先感谢您。
Gabriele。
编辑在回答sw3n
也许我理解的感谢sw3n。下面的代码工作,但这是完全正确的?
// All this code is implemented inside the MyViewController class.
// Attached to an UIButton;
- (void)loadNewController:(id)sender {
[self performSegueWithIdentifier:@"newControllerIdentifier" sender:sender];
}
- (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender {
// As suggested by sw3n
// Load the storyboard from file.
UIStoryboard *storyboardTest = [UIStoryboard storyboardWithName:@"StoryBoardLoad_Test" bundle:nil];
// Instantiate the viewController that live in the storyboard file
UIViewController *destinationViewController = [storyboardTest instantiateViewControllerWithIdentifier:@"newControllerIdentifier"];
// Instantiate a segue to start the chain
UIStoryboardSegue *segue = [[UIStoryboardSegue alloc] initWithIdentifier:identifier source:self destination:destinationViewController];
[self prepareForSegue:segue sender:sender];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"newControllerIdentifier"]) {
[segue.destinationViewController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
// Are there new options to present the controller?
// If I was in a NavigationController a could obviously push it.
[self presentModalViewController:segue.destinationViewController animated:YES];
}
}
这不会回答我的问题。这是storyboard在单个.storyboard文件中的工作方式。我有兴趣使用多个故事板文件。 – Gabriele