Msmit1993
Msmit1993

Reputation: 1710

Storyboard returns nil need some quick advise how to instantiate

I run into the following problem. In my iPad app using storyboard.

-(UIViewController *)SetDetailVideoView
{
    // assign/instantiate self. storyboard, but how?
    VideosViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"VideoViewController"]; //empty but why? Because self.storyboard is empty
    NSLog(@"%@",self.storyboard); //NULL
    return vc;
}

Self.storyboard returns nil so everything it try to get return nil and gives an exemption? So how do i instantiate self.storboard.

Upvotes: 4

Views: 5189

Answers (2)

d.ennis
d.ennis

Reputation: 3455

I don't like the hard coded style. You can also use:

[self.navigationController.storyboard instantiateViewControllerWithIdentifier:@"VideoViewController"];

Upvotes: 2

Hemant Singh Rathore
Hemant Singh Rathore

Reputation: 2139

Use below code to instantiate your storyboard

self.storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad" bundle:nil];

Upvotes: 5

Related Questions