Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open View Controller programmatically and not using a Seque [closed]

I know that this is a really simple question but I am getting nowhere.

I have a storyboard and all the view controllers are opened using segues which is fine, but I would like to open one of them using code when the button is pressed.

What is the line for opening the view controller called ViewControllerMonitorMenu when the testSliders button is pressed:

- (IBAction)testSliders:(id)sender
{

}
like image 788
RGriffiths Avatar asked Mar 28 '13 15:03

RGriffiths


2 Answers

I have finally got it. Thanks for everyone's help:

ViewControllerMonitorMenu *monitorMenuViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewControllerMonitorMenu"];
[self presentViewController:monitorMenuViewController animated:NO completion:nil];
like image 122
RGriffiths Avatar answered Oct 19 '22 19:10

RGriffiths


This code programatically created object of ViewControllerMonitorMenu and also you can go on it.

- (IBAction)testSliders:(id)sender 
    {
       ViewControllerMonitorMenu * object = [[ViewControllerMonitorMenu alloc] init];
        [self presentViewController:object animated:YES completion:nil];

    }
like image 26
iPatel Avatar answered Oct 19 '22 20:10

iPatel