Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Presenting a view controller in tvOS

I am trying to present a view controller in a tvOS application, but neither of the included code snippets present one. What am I missing?

Code 1 :

 DinoViewController *dinoVC = [[DinoViewController alloc]init];
        dinoVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
        [self presentViewController:dinoVC animated:YES completion:nil];

Code 2 :

   UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        DinoViewController *dinoVC = [storyboard instantiateInitialViewController];
        dinoVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
        [self presentViewController:dinoVC animated:YES completion:nil];
like image 311
iOS.Lover Avatar asked Nov 21 '15 19:11

iOS.Lover


Video Answer


2 Answers

Found the correct answer: Mention Identifier in the tvOS storyboard, (not the same in iOS,) and then implement this code:

 UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UIViewController *dinoVC = [storyboard instantiateViewControllerWithIdentifier:@"Page1"];
    [self presentViewController:dinoVC animated:YES completion:nil];
like image 65
iOS.Lover Avatar answered Sep 28 '22 07:09

iOS.Lover


Please try this..

 DinoViewController *dinoVC = [[DinoViewController alloc]init];
        dinoVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

   [self showViewController:dinoVC sender:nil];

hope this will hope u

like image 37
user3306145 Avatar answered Sep 28 '22 06:09

user3306145