项目结构
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 文件,如下图操作