Reputation: 11861
I have a view controller like in the image below:
And I am trying to present this view controller from another view controller like so:
LHPDFFile *vc = [[LHPDFFile alloc] init];
vc.previewItemURL = self->_previewItemURL;
UINavigationController *navBar=[[UINavigationController alloc]initWithRootViewController:vc];
[self presentViewController:navBar animated:YES completion:nil];
This works, however my buttons are not appearing :(
It appears that the code above is creating a Navigation Controller instead of using mine with the buttons. What am I doing wrong?
Upvotes: 0
Views: 2900
Reputation: 119272
You init
none of your controllers from storyboard! Those buttons belongs to file
view controller. You should init
that controller from storyboard instead of call init
.
MyViewController *vc = [[self storyboard] instantiateViewControllerWithIdentifier: @"MyViewControllerStoryBoardID"];
UINavigationController *navBar = [[UINavigationController alloc]initWithRootViewController:vc];
[self presentViewController:navBar animated:YES completion:nil];
Upvotes: 0
Reputation: 2084
Try instantiating your view controller with the storyboard. Something like:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"YourStoryboardName" bundle:nil];
LHPDFFile *vc = (LHPDFFile *)[storyboard instantiateViewControllerWithIdentifier:@"<id of your view controller in the storyboard>"];
Calling the empty init
method leads to empty instantiation of the view, because you have never mentioned that it should use this storyboard's this view controller. More details here.
Upvotes: 2