alex
alex

Reputation: 105

Can I go to another view without a StoryBoard segue? Just with a call from a view?

SO I would like to know if there is a possibility to make a call from a view in the code to go to another view, not using segue.

Thanks for the help.

Upvotes: 5

Views: 7556

Answers (2)

Dan F
Dan F

Reputation: 17732

Yes, if you are using a navigation controller, you simply need to push onto the navigation controller:

[self.navigationController pushViewController:otherViewCon animated:YES];

Or, if you want a modal transition:

[self presentModalViewController:otherViewCon animated:YES];

This is all assuming self is a UIViewController.

To get otherViewCon from a storyboard designed view controller:

otherViewCon = [self.storyboard instantiateViewControllerWithIdentifier:@"Other View"];

Upvotes: 7

Dustin
Dustin

Reputation: 6803

Example of presenting a popover:

    //Declare popover controller
    UIPopoverController *paparazzi;

   //Just some Interface Builder action (could be triggered by a button)
    - (IBAction)sigFocus:(id)sender
    {
        //A view controller being made from a xib file
        SigPopView *temp = [[SigPopView alloc] initWithNibName:@"SigPopView" bundle:nil];

        //Sets the view controller to be displayed
        paparazzi = [[UIPopoverController alloc] initWithContentViewController:temp];

        //Set size
        [paparazzi setPopoverContentSize:CGSizeMake(480,179)];

        //Show controller
        [paparazzi presentPopoverFromRect:theSignature.frame inView:(UIView *)self.delegate permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    }

Upvotes: 0

Related Questions