项目结构

storyboard 跳转到 xib
restaurantViewController *vc = [[restaurantViewController alloc] initWithNibName:@"restaurantViewController" bundle:[NSBundle mainBundle]];
[self presentViewController:vc animated:YES completion:^{
NSLog(@"进入");
}];
xib 跳转到 storyboard
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
ViewController *vc = [sb instantiateViewControllerWithIdentifier:@"main"];
[self presentViewController:vc animated:YES completion:^{
NSLog(@"退回");
}];
注意:
[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]]; 代码中的Main是 storyboard 文件的名字。
ViewController *vc = [sb instantiateViewControllerWithIdentifier:@"main"]; 代码中main是 Storyboard ID,如何设置呢,点击要跳转的 storyboard 文件,如下图操作

本文详细介绍了在iOS开发中,如何从Storyboard跳转到XIB,以及从XIB跳转回Storyboard的方法。提供了具体的代码示例,包括初始化ViewController和使用presentViewController进行跳转的完整过程。
1706

被折叠的 条评论
为什么被折叠?



