How to load a storyboard from a XIB file?

前端 未结 1 1723
日久生厌
日久生厌 2021-01-03 15:03

I am trying to load a storyboard file from a XIB file when a button is clicked. So in the IBAction method I have called the following line:

- (I         


        
相关标签:
1条回答
  • 2021-01-03 15:52

    You are setting the class name of the view controller only. I can see that the storyboard ID filed as empty. Set the Storyboard ID to StoryViewController in the Identity section

    enter image description here

    - (IBAction)NextView:(id)sender
    {
        UIStoryboard *mainStoryBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
        StoryViewController *storyViewController = [mainStoryBoard instantiateViewControllerWithIdentifier:@"StoryViewController"]; 
        [self presentViewController:storyViewController animated:YES completion:nil]; //  present it  
         //[self.navigationController pushViewController:storyViewController animated:YES];// or push it
    
     }
    
    0 讨论(0)
提交回复
热议问题