在开发中我们会有这种需求从一个故事板跳到另一个故事板
modal
1 UIStoryboard *secondStoryboard = [UIStoryboard storyboardWithName:@"Storyboard1" bundle:nil];//获取故事板 2 UIViewController *firstVC = [secondStoryboard instantiateViewControllerWithIdentifier:@"firstVC "];//获取故事板中的页面 3 [self presentViewController:firstVC animated:YES completion: nil];
push
1 UIStoryboard *secondStoryboard = [UIStoryboard storyboardWithName:@"Storyboard1" bundle:nil]; 2 UIViewController *firstVC = [secondStoryboard instantiateViewControllerWithIdentifier:@"firstVC "]; 3 [self.navigationController pushViewController:firstVC animated:NO];
注:获取故事板中的页面有两种方法
- (id)instantiateInitialViewController;//默认加载故事板中入口的页面
- (id)instantiateViewControllerWithIdentifier:(NSString *)identifier;//按照指定ID找页面,可以加载故事板中任意的页面
时间: 2024-10-05 09:33:29