Call storyboard scene programmatically (without needing segue)?

前端 未结 8 827
既然无缘
既然无缘 2020-12-04 10:10

I have a modal storyboard scene that I want to be accessible to all my other scenes. Creating a modal segue to it from every scene on my storyboard creates a big mess of str

8条回答
  •  忘掉有多难
    2020-12-04 10:18

    In the storyboard give your view controller an identifier (under the Attributes Inspector) then use the following code to bring that view forward.

    UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"STORYBOARDNAME" bundle:nil];
    UIViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"VIEWCONTROLLERIDENTIFIER"];
    [self presentModalViewController:vc animated:YES];
    

提交回复
热议问题