Creating a segue programmatically

前端 未结 13 1094
名媛妹妹
名媛妹妹 2020-11-22 12:41

I have a common UIViewController that all my UIViewsControllers extend to reuse some common operations.

I want to set up a segue on this \"

13条回答
  •  迷失自我
    2020-11-22 13:19

    I've been using this code to instantiate my custom segue subclass and run it programmatically. It seems to work. Anything wrong with this? I'm puzzled, reading all the other answers saying it cannot be done.

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

提交回复
热议问题