Search code examples
objective-cxcodesegueuistoryboardsegue

How to create segue in Objective c programmatically?


Now I use wizard to create a segue, but I want it to be Objective C code. Below is my picture of my segue that I want it to be code. Help me please because It is really helpful to me.

enter image description here


Solution

  • UIViewController *nextVC = [self.storyboard instantiateViewControllerWithIdentifier:@"nextVCIdentifier"];
    MyCustomSegue *segue = [[MyCustomSegue alloc] initWithIdentifier:@"" source:self destination:nextVC];
    [self prepareForSegue:segue sender:sender];
    [segue perform];
    

    Simple example. You need to change MyCustomSegue = SWRevealControllerSegue.