Call storyboard scene programmatically (without needing segue)?

前端 未结 8 822
既然无缘
既然无缘 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:20

    Note: the method presentModalViewController:animated is deprecated in iOS 6.

    The new code should read:

    NSString * storyboardName = @"MainStoryboard_iPhone";
    NSString * viewControllerID = @"ViewID";
    UIStoryboard * storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
    MyViewController * controller = (MyViewController *)[storyboard instantiateViewControllerWithIdentifier:viewControllerID];
    [self presentViewController:controller animated:YES completion:nil];
    

提交回复
热议问题