我试图在tvOS应用程序中呈现一个视图控制器,但是所包含的代码片段都没有.我错过了什么?
代码1:
DinoViewController *dinoVC = [[DinoViewController alloc]init]; dinoVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; [self presentViewController:dinoVC animated:YES completion:nil];
代码2:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; DinoViewController *dinoVC = [storyboard instantiateInitialViewController]; dinoVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; [self presentViewController:dinoVC animated:YES completion:nil];
解决方法
找到了正确答案:在tvOS故事板中提及标识符(在iOS中不一样),然后实现此代码:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; UIViewController *dinoVC = [storyboard instantiateViewControllerWithIdentifier:@"Page1"]; [self presentViewController:dinoVC animated:YES completion:nil];