hanumanDev
hanumanDev

Reputation: 6614

Linking it to a certain view controller within the Storyboard?

I have an action that I need to have linked to a certain view in the Storyboard. The code I currently have below links to the Storyboard's first view. How would I link it to a certain view controller within the Storyboard? FYI - this link is coming from a xib file that's not part of the Storyboard and it works fine. thanks

  - (IBAction)continueWithoutLoginButtonTouchHandler:(id)sender 
    {

        UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
        UIViewController* initialHelpView = [storyboard instantiateInitialViewController];

        initialHelpView.modalPresentationStyle = UIModalPresentationFormSheet;
        [self presentModalViewController:initialHelpView animated:YES];
    }

I'm wondering if the method: instantiateViewControllerWithIdentifier: and then identifying one of the views in the storyboard would work.

 - (IBAction)continueWithoutLoginButtonTouchHandler:(id)sender 
{

    UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
   // UIViewController* viewController = [storyboard instantiateInitialViewController];

    UIViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"RotationVC"];

    viewController.modalPresentationStyle = UIModalPresentationFormSheet;
    [self presentModalViewController:viewController animated:YES];
}

thanks for any help

Upvotes: 1

Views: 2468

Answers (1)

hanumanDev
hanumanDev

Reputation: 6614

use the method: instantiateViewControllerWithIdentifier: and then identifying one of the views in the storyboard:

 - (IBAction)continueWithoutLoginButtonTouchHandler:(id)sender 
{

    UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
   // UIViewController* viewController = [storyboard instantiateInitialViewController];

    UIViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"RotationVC"];

    viewController.modalPresentationStyle = UIModalPresentationFormSheet;
    [self presentModalViewController:viewController animated:YES];
}

Upvotes: 2

Related Questions