objective-c – 在tvOS中呈现视图控制器

前端之家收集整理的这篇文章主要介绍了objective-c – 在tvOS中呈现视图控制器前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图在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];

猜你在找的C&C++相关文章